Remove command parameter from Group.on_error callback

Similar to the CommandTree.on_error removal, this one can be retrieved
using Interaction.command
This commit is contained in:
Rapptz 2022-04-13 22:45:06 -04:00
parent ce15df4275
commit 4951231a7c

View File

@ -556,10 +556,10 @@ class Command(Generic[GroupT, P, T]):
parent = self.parent
if parent is not None:
await parent.on_error(interaction, self, error)
await parent.on_error(interaction, error)
if parent.parent is not None:
await parent.parent.on_error(interaction, self, error)
await parent.parent.on_error(interaction, error)
def _has_any_error_handlers(self) -> bool:
if self.on_error is not None:
@ -1159,19 +1159,19 @@ class Group:
if isinstance(command, Group):
yield from command.walk_commands()
async def on_error(self, interaction: Interaction, command: Command[Any, ..., Any], error: AppCommandError) -> None:
async def on_error(self, interaction: Interaction, error: AppCommandError) -> None:
"""|coro|
A callback that is called when a child's command raises an :exc:`AppCommandError`.
To get the command that failed, :attr:`discord.Interaction.command` should be used.
The default implementation does nothing.
Parameters
-----------
interaction: :class:`~discord.Interaction`
The interaction that is being handled.
command: :class:`~discord.app_commands.Command`
The command that failed.
error: :exc:`AppCommandError`
The exception that was raised.
"""