如何解决如何在代码中添加冷却时间消息?
@client.command()
@commands.has_permissions(administrator=True)
@commands.cooldown(1,60,commands.BucketType.user)
async def nuke(ctx,amount=500):
await ctx.channel.purge(limit=amount + 1)
await ctx.send(f'Channel has been Nuked!')
@nuke.error
async def nuke_error(ctx,error):
if isinstance(error,commands.MissingPermissions):
await ctx.send('You do not have permissions to use this command!')
只是想知道如何为此添加冷却时间消息,它说:“您必须等待60秒才能再次使用此命令!”
解决方法
您可以使用
if isinstance(error,commands.CommandOnCooldown):
await ctx.send("You must wait 60 seconds before you can use this command again!")
在nuke_error
函数中。这会起作用。
,您可以使用它来发送错误以及剩余的秒数。
@nuke.error
async def nuke_cooldown(ctx,error):
if isinstance(error,commands.CommandOnCooldown):
await ctx.send(error)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。