3 回答

TA贡献1818条经验 获得超7个赞
@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')
test.reset_cooldown(ctx)
elif command.lower() == '2':
await ctx.send('I want this to have a Cooldown')
本质上,正是上面那个人所说的,但没有await. 尝试了他的代码,但它没有用,幸运的是我能够找到指向正确方向的资源。

TA贡献1772条经验 获得超8个赞
@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')
test.reset_cooldown(ctx)
elif command.lower() == '2':
await ctx.send('I want this to have a Cooldown')
await test.reset_cooldown(ctx)将为调用该命令的用户重置冷却时间。

TA贡献1811条经验 获得超5个赞
@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')
ctx.command.reset_cooldown(ctx)
# reset_cooldown is an attribute of `Command`, not `function`
elif command.lower() == '2':
await ctx.send('I want this to have a Cooldown')
对于将来的参考和新读者,Discord.py 扩展 (discord.etx) 以不同的方式执行此操作,并在 1.4 文档中进行了说明。
不是调用reset_cooldown函数,而是调用Command来自Context( ctx.command) 的对象。
资料来源:discord.ext.commands.Command.reset_cooldown
我也必须自己找出答案,因为我的冷却功能会在不值得冷却五分钟的地方返回。
添加回答
举报