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
我也必須自己找出答案,因為我的冷卻功能會在不值得冷卻五分鐘的地方返回。
添加回答
舉報