[英]Command Cooldown - discord.py
所以我对如何制作这样的功能做了一些研究,这就是我想出的:
@bot.command()
@commands.cooldown(1, 30, commands.BucketType.user)
async def test(ctx):
try:
await ctx.send("Success")
except commands.errors.CommandOnCooldown:
await ctx.send("This command is on cooldown")
让机器人发送这样的信息的最佳方法是什么:“你正在冷却,26 秒后再试”? 我试图在except commands.errors.CommandOnCooldown:
的行中执行此except commands.errors.CommandOnCooldown:
但这不起作用。
非常感谢任何帮助
您可以使用Command.error()
处理错误
@bot.command()
@commands.cooldown(1, 30, commands.BucketType.user)
async def test(ctx):
await ctx.send("Success")
@test.error
async def test_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(error)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.