mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-15 10:19:59 +00:00
Fix cog_app_command_error for group edge case
This commit is contained in:
parent
6d1069e789
commit
1fbcfbd1fb
@ -613,7 +613,7 @@ class Command(Generic[GroupT, P, T]):
|
||||
if parent.parent is not None:
|
||||
await parent.parent.on_error(interaction, error)
|
||||
|
||||
binding_error_handler = getattr(self.binding, '__app_commands_error_handler__', None)
|
||||
binding_error_handler = getattr(self.binding, '__discord_app_commands_error_handler__', None)
|
||||
if binding_error_handler is not None:
|
||||
await binding_error_handler(interaction, error)
|
||||
|
||||
@ -1143,6 +1143,9 @@ class Group:
|
||||
__discord_app_commands_guild_only__: bool = MISSING
|
||||
__discord_app_commands_default_permissions__: Optional[Permissions] = MISSING
|
||||
__discord_app_commands_has_module__: bool = False
|
||||
__discord_app_commands_error_handler__: Optional[
|
||||
Callable[[Interaction, AppCommandError], Coroutine[Any, Any, None]]
|
||||
] = None
|
||||
|
||||
def __init_subclass__(
|
||||
cls,
|
||||
@ -1269,10 +1272,6 @@ class Group:
|
||||
raise ValueError('groups can only be nested at most one level')
|
||||
parent.add_command(self)
|
||||
|
||||
self.__app_commands_error_handler__: Optional[
|
||||
Callable[[Interaction, AppCommandError], Coroutine[Any, Any, None]]
|
||||
] = None
|
||||
|
||||
def __set_name__(self, owner: Type[Any], name: str) -> None:
|
||||
self._attr = name
|
||||
self.module = owner.__module__
|
||||
|
@ -268,7 +268,7 @@ class Cog(metaclass=CogMeta):
|
||||
__cog_listeners__: List[Tuple[str, str]]
|
||||
__cog_is_app_commands_group__: ClassVar[bool] = False
|
||||
__cog_app_commands_group__: Optional[app_commands.Group]
|
||||
__app_commands_error_handler__: Optional[
|
||||
__discord_app_commands_error_handler__: Optional[
|
||||
Callable[[discord.Interaction, app_commands.AppCommandError], Coroutine[Any, Any, None]]
|
||||
]
|
||||
|
||||
@ -333,7 +333,7 @@ class Cog(metaclass=CogMeta):
|
||||
else:
|
||||
error_handler = None
|
||||
|
||||
self.__app_commands_error_handler__ = error_handler
|
||||
self.__discord_app_commands_error_handler__ = error_handler
|
||||
|
||||
for command in cls.__cog_app_commands__:
|
||||
copy = command._copy_with(parent=self.__cog_app_commands_group__, binding=self)
|
||||
@ -343,7 +343,10 @@ class Cog(metaclass=CogMeta):
|
||||
setattr(self, copy._attr, copy)
|
||||
|
||||
if isinstance(copy, app_commands.Group):
|
||||
copy.__app_commands_error_handler__ = error_handler
|
||||
copy.__discord_app_commands_error_handler__ = error_handler
|
||||
for command in copy._children.values():
|
||||
if isinstance(command, app_commands.Group):
|
||||
command.__discord_app_commands_error_handler__ = error_handler
|
||||
|
||||
children.append(copy)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user