Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subcommands having MISSING cog attribute #1594

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,6 @@ def _update_copy(self, kwargs: Dict[str, Any]):
else:
return self.copy()

def _set_cog(self, cog):
Dorukyum marked this conversation as resolved.
Show resolved Hide resolved
super()._set_cog(cog)
self._validate_parameters()


class SlashCommandGroup(ApplicationCommand):
r"""A class that implements the protocol for a slash command group.
Expand Down Expand Up @@ -1090,10 +1086,16 @@ def to_dict(self) -> Dict:

return as_dict

def add_command(self, command: SlashCommand) -> None:
if command.cog is MISSING:
command.cog = self.cog

self.subcommands.append(command)

def command(self, cls: Type[T] = SlashCommand, **kwargs) -> Callable[[Callable], SlashCommand]:
def wrap(func) -> T:
command = cls(func, parent=self, **kwargs)
self.subcommands.append(command)
self.add_command(command)
return command

return wrap
Expand Down