Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
556 views
in Technique[技术] by (71.8m points)

python - How to do a timer command to show all cooldown times remaining from error handler

I am doing a discord bot and some commands have different cooldowns. I wanna know how to make a command that shows all these remaining times.

@bot.command()
@cooldown(1, 3600, BucketType.user)
async def FirstOne(ctx):
...

@FirstOne.error
async def FirstOne_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):

        msg = 'Try again in {:.0f} seconds'.format(error.retry_after)

        await ctx.send(msg)

    else:
        raise error

The code I wanna is something like this:

@bot.command()
async def timer(ctx):
  await ctx.send() #FirstOne_error's msg
question from:https://stackoverflow.com/questions/65906138/how-to-do-a-timer-command-to-show-all-cooldown-times-remaining-from-error-handle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...