Ad

Python 3.6 Discord Bot Cooldown Message

- 1 answer

so I have this command which allows the user to change the game and it works perfectly but I put a 15 second cooldown on it and it too works fine, but my issue is getting it to display a message that you are in cooldown period OR if the command has successfully executed. I'm new to python and this is probably a simple fix so I apologize for wasting your time, but thx in advance

My code:

@client.command(name="status")
@commands.cooldown(1, 15, commands.BucketType.server)
async def client_status(*, status: str = None):
    """Change the bot's 'playing' status.
    Running this command without any arguments will turn the 'playing'     status off'
    """
    game = Game(name=status)
    await client.change_presence(game=game)
Ad

Answer

If a member tries to invoke a command that is currently on cooldown a CommandOnCooldown exception is thrown and triggers on_command_error.

Although async does not document it there is an event on_command_completion

on_command_completion(command, ctx)

this is dispatched if a command has successfully completed its invocation.

Ad
source: stackoverflow.com
Ad