【发布时间】:2021-12-03 17:24:49
【问题描述】:
更新:
我找到了原因, 这是新的工作代码:
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandInvokeError):
return
希望它有效!
【问题讨论】:
标签: python discord discord.py bots
更新:
我找到了原因, 这是新的工作代码:
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandInvokeError):
return
希望它有效!
【问题讨论】:
标签: python discord discord.py bots
试试:
if isinstance(error, discord.Forbidden):
await ctx.send("Bot doesn't have permissions to do this **or** the bot can't do this. Please try again.")
【讨论】:
你的代码没有失败
BotMissingPermissions
试试这个代码
if isinstance(error, commands.CommandNotFound):
或
if isinstance(error, commands.MissingPermissions):
【讨论】:
if isinstance(error, commands.CommandNotFound): 不起作用。如果用户使用 bot 中不存在的错误命令,则会出错。 if isinstance(error, commands.MissingPermissions): 代码不起作用。