discord.py bot getting cooldown time remaining of command

前端 未结 1 1318
庸人自扰
庸人自扰 2020-12-17 07:26

I\'m working on a python based discord bot that has the following command

@client.command(name=\"Mine\",
            description=\"Mine daily.\",
                    


        
相关标签:
1条回答
  • 2020-12-17 08:05

    You'll need to write an error handler for your command that handles the CommandOnCooldown error and sends the message.

    @mine.error
    async def mine_error(ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            msg = 'This command is ratelimited, please try again in {:.2f}s'.format(error.retry_after)
            await ctx.send(msg)
        else:
            raise error
    
    0 讨论(0)
提交回复
热议问题