Discord.py 如何从错误函数重置命令冷却时间

Discord.py 如何从错误函数重置命令冷却时间,discord.py,Discord.py,我有个问题。似乎我不知道如何重置命令冷却时间,而不是在实际的命令本身 @bot.command() @commands.cooldown(1900,type=commands.BucketType.member) 异步def rob(ctx,左:discord.Member): guild=ctx.author.guild server\u members=guild.members 如果留在服务器_成员中: 打印('找到用户') random\u chance=random.randint(0

我有个问题。似乎我不知道如何重置命令冷却时间,而不是在实际的命令本身

@bot.command()
@commands.cooldown(1900,type=commands.BucketType.member)
异步def rob(ctx,左:discord.Member):
guild=ctx.author.guild
server\u members=guild.members
如果留在服务器_成员中:
打印('找到用户')
random\u chance=random.randint(0,1)
如果随机概率==1:
打印('抢劫成功')
其他:
等待ctx.channel.send('抢劫未成功lol noob')
其他:
等待ctx.channel.send('此人不在此服务器中…:sob:')
@罗布·错误
异步def错误(ctx,错误):
如果isinstance(错误,commands.MissingRequiredArgument):
等待ctx.channel.send('你必须提供给我一个人去抢劫..noob')
elif isinstance(错误,commands.BadArgument):
等待ctx.channel.send('您必须向我提供一名有效人员..')
elif isinstance(错误,commands.CommandOnColdDown):
等待ctx.channel.send(f'Chill.Your on cooldown.在{math.ceil(error.retry\u after)}秒后重试)
其他:
raise error``我想让它在roberror函数中重置命令冷却时间。有人能帮我吗?

可以使用
reset\u cooldown
属性重置命令的冷却时间,然后将命令上下文作为参数传递。这是一个使用它的例子

rob
是命令标识符,然后
reset\u cooldown
是属性。此示例将重置命令的冷却时间

rob.reset_cooldown(ctx)
当“rob”命令不成功时,您似乎想将其放入,您可以这样添加:

else:
    await ctx.channel.send('Robbery not successful lol noob')
    rob.reset_cooldown(ctx)

您可以在文档中找到更多信息:

任何帮助都将不胜感激!事实上,不,我想你一定是看错问题了。我需要做的是在实际的错误处理程序中重置冷却时间,而不是在命令本身中。你也可以把它放在那里@初学者PythonLearner,这就是一个例子哦。。好的,非常感谢。如果答案有用的话,你介意标记一下吗?已经做了:))