Skip to content

Commit f68d8a2

Browse files
committed
Add unhandled_by_cog parameter to ModmailBot.on_command_error:
- Resolve #3170
1 parent 48ad5c4 commit f68d8a2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bot.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,17 @@ async def on_error(self, event_method, *args, **kwargs):
15111511
logger.error("Ignoring exception in %s.", event_method)
15121512
logger.error("Unexpected exception:", exc_info=sys.exc_info())
15131513

1514-
async def on_command_error(self, context, exception):
1514+
async def on_command_error(
1515+
self, context: commands.Context, exception: Exception, *, unhandled_by_cog: bool = False
1516+
) -> None:
1517+
if not unhandled_by_cog:
1518+
command = context.command
1519+
if command and command.has_error_handler():
1520+
return
1521+
cog = context.cog
1522+
if cog and cog.has_error_handler():
1523+
return
1524+
15151525
if isinstance(exception, (commands.BadArgument, commands.BadUnionArgument)):
15161526
await context.typing()
15171527
await context.send(embed=discord.Embed(color=self.error_color, description=str(exception)))

0 commit comments

Comments
 (0)