mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-24 10:02:56 +00:00
[commands] Add cog-level app command error special method
This commit is contained in:
@@ -598,7 +598,7 @@ class Command(Generic[GroupT, P, T]):
|
||||
|
||||
return base
|
||||
|
||||
async def _invoke_error_handler(self, interaction: Interaction, error: AppCommandError) -> None:
|
||||
async def _invoke_error_handlers(self, interaction: Interaction, error: AppCommandError) -> None:
|
||||
# These type ignores are because the type checker can't narrow this type properly.
|
||||
if self.on_error is not None:
|
||||
if self.binding is not None:
|
||||
@@ -613,6 +613,10 @@ class Command(Generic[GroupT, P, T]):
|
||||
if parent.parent is not None:
|
||||
await parent.parent.on_error(interaction, error)
|
||||
|
||||
cog_error = getattr(self.binding, '__app_commands_error_handler__', None)
|
||||
if cog_error is not None:
|
||||
await cog_error(interaction, error)
|
||||
|
||||
def _has_any_error_handlers(self) -> bool:
|
||||
if self.on_error is not None:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user