Skip to content

Commit

Permalink
Add unhandled_by_cog parameter to ModmailBot.on_command_error:
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerrie-Aries committed Aug 24, 2022
1 parent 48ad5c4 commit f68d8a2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,17 @@ async def on_error(self, event_method, *args, **kwargs):
logger.error("Ignoring exception in %s.", event_method)
logger.error("Unexpected exception:", exc_info=sys.exc_info())

async def on_command_error(self, context, exception):
async def on_command_error(
self, context: commands.Context, exception: Exception, *, unhandled_by_cog: bool = False
) -> None:
if not unhandled_by_cog:
command = context.command
if command and command.has_error_handler():
return
cog = context.cog
if cog and cog.has_error_handler():
return

if isinstance(exception, (commands.BadArgument, commands.BadUnionArgument)):
await context.typing()
await context.send(embed=discord.Embed(color=self.error_color, description=str(exception)))
Expand Down

0 comments on commit f68d8a2

Please sign in to comment.