简体   繁体   English

Python 3.6 Discord Bot冷却时间消息

[英]Python 3.6 Discord Bot Cooldown message

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. 所以我有此命令,它允许用户更改游戏,并且能完美运行,但我在游戏上放置了15秒的冷却时间,也很好用,但是我的问题是让它显示您处于冷却时间的消息,或者该命令已成功执行。 I'm new to python and this is probably a simple fix so I apologize for wasting your time, but thx in advance 我是python的新手,这可能是一个简单的修复程序,因此,我很抱歉浪费您的时间,但请提前

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)

If a member tries to invoke a command that is currently on cooldown a CommandOnCooldown exception is thrown and triggers on_command_error . 如果成员尝试调用当前处于冷却状态的命令,则会引发CommandOnCooldown异常并触发on_command_error

Although async does not document it there is an event on_command_completion 尽管异步没有记录它,但是有一个on_command_completion事件

on_command_completion(command, ctx)

this is dispatched if a command has successfully completed its invocation. 如果命令已成功完成其调用,则调度此事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM