Issue
I want to make a timer command.
@commands.command()
async def timer(self, ctx, seconds):
try:
secondint = int(seconds)
if secondint > 300:
await ctx.send("I dont think im allowed to do go above 300 seconds.")
raise BaseException
if secondint < 0 or secondint == 0:
await ctx.send("I dont think im allowed to do negatives")
raise BaseException
message = await ctx.send("Timer: " + seconds)
while True:
secondint = secondint - 1
if secondint == 0:
await message.edit(new_content=("Ended!"))
break
await message.edit(new_content=("Timer: {0}".format(secondint)))
await asyncio.sleep(1)
await ctx.send(ctx.message.author.mention + " Your countdown Has ended!")
except ValueError:
await ctx.send("Must be a number!")
I tried this but this doesn't work , it doesn't edit message like I want it to and no errors.
Solution
It doesn't edit the message since new_content
isn't a Message.edit()
method argument.
It only has: content / embed / suppress / delete_after / allowed_mentions.
The one you're looking for is content
:
@commands.command()
async def timer(self, ctx, seconds):
try:
secondint = int(seconds)
if secondint > 300:
await ctx.send("I dont think im allowed to do go above 300 seconds.")
raise BaseException
if secondint <= 0:
await ctx.send("I dont think im allowed to do negatives")
raise BaseException
message = await ctx.send("Timer: {seconds}")
while True:
secondint -= 1
if secondint == 0:
await message.edit(content="Ended!")
break
await message.edit(content=f"Timer: {secondint}")
await asyncio.sleep(1)
await ctx.send(f"{ctx.author.mention} Your countdown Has ended!")
except ValueError:
await ctx.send("Must be a number!")
Answered By - MrSpaar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.