Skip to content

Commit 60aca0f

Browse files
committed
Fix for subcommands using self
1 parent 03e3c93 commit 60aca0f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

discord/commands/commands.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ def __init__(self, func: Callable, *args, **kwargs) -> None:
385385
validate_chat_input_description(description)
386386
self.description: str = description
387387
self.parent = kwargs.get('parent')
388+
self.attached_to_group: bool = False
388389

389390
self.cog = None
390391

@@ -527,6 +528,8 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
527528

528529
if self.cog is not None:
529530
await self.callback(self.cog, ctx, **kwargs)
531+
elif self.parent is not None and self.attached_to_group is True:
532+
await self.callback(self.parent, ctx, **kwargs)
530533
else:
531534
await self.callback(ctx, **kwargs)
532535

@@ -728,6 +731,7 @@ def __new__(cls, *args, **kwargs) -> SlashCommandGroup:
728731
for i, c in cls.__dict__.items():
729732
if isinstance(c, (SlashCommand, SlashCommandGroup)):
730733
c.parent = self
734+
c.attached_to_group = True
731735
self.__initial_commands__.append(c)
732736

733737
return self

0 commit comments

Comments
 (0)