mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 08:44:10 +00:00
Fix cog_app_command_error for groups
This commit is contained in:
parent
b80cb47caf
commit
6d1069e789
@ -1269,6 +1269,10 @@ 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__
|
||||
|
@ -328,6 +328,13 @@ class Cog(metaclass=CogMeta):
|
||||
if self.__cog_app_commands_group__:
|
||||
children.append(app_command)
|
||||
|
||||
if Cog._get_overridden_method(self.cog_app_command_error) is not None:
|
||||
error_handler = self.cog_app_command_error
|
||||
else:
|
||||
error_handler = None
|
||||
|
||||
self.__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)
|
||||
|
||||
@ -335,6 +342,9 @@ class Cog(metaclass=CogMeta):
|
||||
if copy._attr:
|
||||
setattr(self, copy._attr, copy)
|
||||
|
||||
if isinstance(copy, app_commands.Group):
|
||||
copy.__app_commands_error_handler__ = error_handler
|
||||
|
||||
children.append(copy)
|
||||
|
||||
self.__cog_app_commands__ = children
|
||||
@ -346,11 +356,6 @@ class Cog(metaclass=CogMeta):
|
||||
|
||||
self.__cog_app_commands_group__._children = mapping # type: ignore # Variance issue
|
||||
|
||||
if Cog._get_overridden_method(self.cog_app_command_error) is not None:
|
||||
self.__app_commands_error_handler__ = self.cog_app_command_error
|
||||
else:
|
||||
self.__app_commands_error_handler__ = None
|
||||
|
||||
return self
|
||||
|
||||
def get_commands(self) -> List[Command[Self, ..., Any]]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user