【问题标题】:Python 3.6 Discord Bot Cooldown messagePython 3.6 Discord Bot 冷却消息
【发布时间】:2018-07-07 05:08:41
【问题描述】:

所以我有这个命令,它允许用户更改游戏,它运行良好,但我对其设置了 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)

【问题讨论】:

    标签: python bots discord


    【解决方案1】:

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

    虽然 async 没有记录它,但有一个事件 on_command_completion

    on_command_completion(command, ctx)
    

    如果命令已成功完成其调用,则会调度此消息。

    【讨论】:

      猜你喜欢
      • 2018-05-03
      • 1970-01-01
      • 2017-11-21
      • 2018-02-15
      • 2021-03-27
      • 2021-10-30
      • 2021-09-07
      • 2018-07-08
      • 2022-07-11
      相关资源
      最近更新 更多