Updated Error Handler

This commit is contained in:
Dustin Pianalto 2018-06-15 00:24:39 -08:00
parent 7f0d31f4a5
commit 65d99cdd85

View File

@ -99,20 +99,20 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
# message. # message.
# If command is not found, return # If command is not found, return
em = discord.Embed(colour=self.error_color)
if isinstance(error, discord.ext.commands.errors.CommandNotFound): if isinstance(error, discord.ext.commands.errors.CommandNotFound):
return em.title = 'Command Not Found'
em.description = f'{ctx.prefix}{ctx.command} is not a valid command.'
else:
error = error.__cause__ or error error = error.__cause__ or error
tb = traceback.format_exception(type(error), error, error.__traceback__, limit=2, chain=False) tb = traceback.format_exception(type(error), error, error.__traceback__, limit=2, chain=False)
tb = ''.join(tb) tb = ''.join(tb)
joke = random.choice(jokes) joke = random.choice(jokes)
fmt = f'**`{self.defaultprefix}{ctx.command}`**\n{joke}\n\n**{type(error).__name__}:**:\n```py\n{tb}\n```' fmt = f'**`{self.defaultprefix}{ctx.command}`**\n{joke}\n\n**{type(error).__name__}:**:\n```py\n{tb}\n```'
em.title = f'{type(error)} in command {ctx.prefix}{ctx.command}'
em.description = str(error)
# Stops the error handler erroring. await ctx.send(embed=em)
try:
await ctx.send(fmt)
except:
traceback.print_exc()
async def on_message(self, message): async def on_message(self, message):
# Make sure people can't change the username # Make sure people can't change the username