Python 3.6 Discord Bot冷却时间消息 [英] Python 3.6 Discord Bot Cooldown message

查看:74
本文介绍了Python 3.6 Discord Bot冷却时间消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有此命令,它允许用户更改游戏,并且效果很好,但是我在上面放了15秒的冷却时间,效果也很好,但是我的问题是让它显示您处于冷却状态的消息句号,或者如果命令已成功执行.我是python的新手,这可能是一个简单的修复程序,因此,我很抱歉浪费您的时间,但请提前

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

我的代码:

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

推荐答案

如果成员尝试调用当前处于冷却状态的命令,则 on_command_error .

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

尽管异步没有记录它,但是有一个事件 on_command_completion

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.

这篇关于Python 3.6 Discord Bot冷却时间消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆