def on_command_error(self, exception, context):
"""
Override bot.on_command_error function.
Error handling function.
"""
if isinstance(exception, discord.ext.commands.errors.CommandNotFound):
msg = """Sorry, this command is unknown to me... :japanese_ogre:\
\nDo you need help? \
\nIf so, just type ***!help*** :sunglasses:"""
elif isinstance(exception,
discord.ext.commands.errors.DisabledCommand):
msg = ":sleeping:"
elif isinstance(exception,
discord.ext.commands.errors.CheckFailure):
msg = """:octagonal_sign: you are not allowed to do this.\
\nOnly an :alien: can wake me up..."""
elif isinstance(exception,
discord.ext.commands.errors.MissingRequiredArgument):
msg = """:thought_balloon: You forgot parameters.\
\nType !help [command] to get help :interrobang:"""
elif isinstance(exception,
APIconnectionError):
msg = """It seems we can't contact the API...:frowning2: \
\nTake a rest and retry later.:play_pause: """
elif isinstance(exception,
discord.ext.commands.errors.CommandInvokeError):
msg = "oups... " + str(exception)
print(msg)
else:
msg = "oups inconnu... " + str(type(exception)) + str(exception)
print(msg)
await self.send_message(context.message.channel, msg)
评论列表
文章目录