Fix cog_app_command_error for groups

This commit is contained in:
Stocker
2022-07-27 00:29:53 -04:00
committed by GitHub
parent b80cb47caf
commit 6d1069e789
2 changed files with 14 additions and 5 deletions

View File

@ -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]]: