【发布时间】:2020-04-22 05:40:00
【问题描述】:
所以我为我的不和谐机器人制作了一个错误处理程序。我相信我已经将所有实例都放入了 if 语句中。但是,当发生错误时,它一次会发送 2-3 个错误实例消息。我怎样才能解决这个问题?我在想一个错误消息计数器,但我不知道该怎么做。
这是我的处理程序:
错误处理程序
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CheckFailure):
await ctx.send("[HANDLER] You do not have the required role to use this command!")
print(error)
if isinstance(error, commands.MissingPermissions):
await ctx.send("[HANDLER] You do not have sufficient permission settings to use this command!")
print(error)
if isinstance(error, commands.UserInputError):
await ctx.send("[HANDLER] Invalid input! You have most likely typed something wrong; check spelling and try again. Use $help for more information.")
print(error)
if isinstance(error, commands.CommandNotFound):
await ctx.send("[HANDLER] That command doesn't exist! You may have typed it wrong, try again. Use $help for more information")
print(error)
if isinstance(error, commands.BotMissingPermissions):
await ctx.send("[HANDLER] I'm missing the permissions to use this command!")
print(error)
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("[HANDLER] You missed an argument! For help do $help [command].")
print(error)
if isinstance(error, commands.BadArgument):
await ctx.send("[HANDLER] Could not find that value!")
print(error)
if isinstance(error, commands.DisabledCommand):
await ctx.send("[HANDLER] This command has been disabled!")
print(error)
if isinstance(error, commands.NoPrivateMessage):
await ctx.send("[HANDLER] This command can not be used inside private messages!")
提前致谢!!!
【问题讨论】:
标签: python bots discord discord.py discord.py-rewrite