【问题标题】:Reseting a cooldown of a command in discord.py在 discord.py 中重置命令的冷却时间
【发布时间】:2021-04-25 00:18:17
【问题描述】:

我一直试图弄清楚 discord.py 或 python 中是否有一些东西会在命令返回时重置命令的冷却时间。例如(如下所示)有人键入!math,但如果有另一个命令正在运行,该命令将不会继续执行,用户必须再次等待 60 秒,因为该命令处于冷却状态。

代码举例:

@bot.command()
@commands.cooldown(1, 60.00, commands.BucketType.guild)
async def math(msg):
    if msg.channel.id != channel:
        return
    if another_command_running:
        await msg.send(msg.author.mention + " Another command is running")
        return
    ....
    ....
    ....

【问题讨论】:

    标签: python pycharm discord


    【解决方案1】:

    可以使用 Discord 的内置功能重置冷却时间:reset_cooldown,在您的情况下,它将重置数学命令的冷却时间,以便用户能够立即再次使用它。

    只需将 附加到命令应该移除冷却时间的位置。

    math.reset_cooldown(ctx)
    

    【讨论】:

      猜你喜欢
      • 2021-03-11
      • 1970-01-01
      • 2021-03-30
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 2021-05-13
      • 2020-10-11
      • 2021-05-15
      相关资源
      最近更新 更多