Python 3.6 Discord Bot Cooldown消息

时间:2018-01-28 10:41:49

标签: python bots discord

所以我有这个命令允许用户改变游戏并且它完美地工作但是我对它施加了15秒的冷却时间它也工作正常,但是我的问题是让它显示一条消息,表明你处于冷却状态句点或命令已成功执行。我是python的新手,这可能是一个简单的解决方案,所以我为浪费你的时间道歉,但提前做好了

我的代码:

@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)

1 个答案:

答案 0 :(得分:0)

如果成员试图调用当前处于冷却状态的命令,则会抛出CommandOnCooldown异常并触发on_command_error

虽然异步不记录,但有一个事件on_command_completion

on_command_completion(command, ctx)

如果命令已成功完成其调用,则调度此方法。

相关问题