我有这个错误处理函数:
@clear.error
async def clear_error(error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send(f'Sorry {ctx.author.mention}, you do not have permissions to do that!')
向阿卜杜勒阿齐兹(Abdulaziz)致谢,阿卜杜拉齐兹向我发送了此
但这不起作用
答案 0 :(得分:0)
首先,您需要从commands
导入discord.ext
。然后,将if isinstance(error, MissingPermissions):
替换为if isinstance(error, commands.MissingPermissions):
代码应如下所示:
from discord.ext import commands
@clear.error
async def clear_error(error, ctx):
if isinstance(error, commands.MissingPermissions):
await ctx.send(f'Sorry {ctx.author.mention}, you do not have permissions to do that!')```