From 41eb77b6863cf83570116b451793013b7ffc91a8 Mon Sep 17 00:00:00 2001 From: Krittick Date: Fri, 28 Jan 2022 19:30:00 -0800 Subject: [PATCH] add missing `guild_ids` parameter to `SlashCommandGroup.create_subgroup` --- discord/commands/core.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/discord/commands/core.py b/discord/commands/core.py index b9efdd0e56..a5124654b3 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -941,12 +941,35 @@ def wrap(func) -> SlashCommand: return wrap - def create_subgroup(self, name, description) -> SlashCommandGroup: + def create_subgroup( + self, name: str, + description: Optional[str] = None, + guild_ids: Optional[List[int]] = None, + ) -> SlashCommandGroup: + """ + Creates a new subgroup for this SlashCommandGroup. + + Parameters + ---------- + name: :class:`str` + The name of the group to create. + description: Optional[:class:`str`] + The description of the group to create. + guild_ids: Optional[List[:class:`int`]] + A list of the IDs of each guild this group should be added to, making it a guild command. + This will be a global command if ``None`` is passed. + + Returns + -------- + SlashCommandGroup + The slash command group that was created. + """ + if self.parent is not None: # TODO: Improve this error message raise Exception("Subcommands can only be nested once") - sub_command_group = SlashCommandGroup(name, description, parent=self) + sub_command_group = SlashCommandGroup(name, description, guild_ids, parent=self) self.subcommands.append(sub_command_group) return sub_command_group