Skip to content

Add unhandled_by_cog parameter to ModmailBot.on_command_error #3178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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