diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index d1db76a7e..83a703b8c 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -757,8 +757,8 @@ class Group: self._children: Dict[str, Union[Command, Group]] = {} for child in self.__discord_app_commands_group_children__: - child = child._copy_with_binding(self) if not cls.__discord_app_commands_skip_init_binding__ else child child.parent = self + child = child._copy_with_binding(self) if not cls.__discord_app_commands_skip_init_binding__ else child self._children[child.name] = child if child._attr and not cls.__discord_app_commands_skip_init_binding__: setattr(self, child._attr, child) diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 59eb54c4e..39a32e3cd 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -249,12 +249,12 @@ class Cog(metaclass=CogMeta): # Register the application commands children: List[Union[app_commands.Group, app_commands.Command[Self, ..., Any]]] = [] for command in cls.__cog_app_commands__: - copy = command._copy_with_binding(self) - if cls.__cog_is_app_commands_group__: # Type checker doesn't understand this type of narrowing. # Not even with TypeGuard somehow. - copy.parent = self # type: ignore + command.parent = self # type: ignore + + copy = command._copy_with_binding(self) children.append(copy) if command._attr: