我的机器人中有两个使用冷却的命令:"suggest“和"repentir”。我已经执行了另一个命令来重置用户的冷却时间,下面是该命令的代码: @client.command()
@commands.check(is_owner)
async def reset(ctx, user:discord.Member):
repentir.reset_cooldown(ctx)
suggest.reset_cooldown(ctx)
await ctx.send("Le cooldown pour <@{}> a bien été réin
因此,我在我的机器人中添加了@commands.cooldown(1, 10, commands.BucketType.user),试图阻止人们向它发送垃圾邮件。我将错误消息设置为: async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f'This command is not ready to use, try again in %.2f seconds' % error.retry_after
我对discord.py和一般的python都很陌生,但我试着学习。我不知道如何将command.reset_cooldown添加到代码中。正如下面的代码所述,我希望!测试忽略冷却,但我希望!测试2有冷却。有人能帮我吗?
@commands.cooldown(1, 30, commands.BucketType.user)
async def test(ctx, command=None):
if command is None:
await ctx.send('I want this to ignore cooldown')
elif comm
我一直在尝试将我的命令转换为on_message事件,因为在这种情况下,它节省了空间,而且看起来更干净。但是,我似乎不能再使用@cooldown(),因为我必须使用commands.Cog.listener()。 有没有其他方法可以让冷却时间起作用?下面列出了我的代码 # Cog on_message for waifus and husbandos
@commands.Cog.listener()
# Cooldown NOT WORKING
@cooldown(1, 1, BucketType.user)
async def on_message(self
我一直在努力寻找如何才能在命令成功后才能执行冷却命令。例如,在下面的代码中,它可以很好地用于冷却命令修饰器,只是在"now_amt“与"max_amt”相同之前,它会发送"amount is too full“,但这是不成功的,如果用户使用另一个命令来降低"now_amt”,用户仍然必须等待完整的时间,即使命令没有做任何事情。 我如何在代码中进行检查,以确保命令已完成,然后它将开始冷却,直到您可以再次使用该命令?如果now_amt是max,那么它就不会开始新的冷却时间。 @client.command()
@commands.cooldown(1, 3600,