Skip to content

Commit 2d762d6

Browse files
IcebluewolfLulalabyPaillat-dev
authored
feat: Documents SlashCommandGroup.add_command (#3346)
* feat: Documents SlashCommandGroup.add_command * chore: Changelog * Update CHANGELOG.md Signed-off-by: Ice Wolfy <44532864+Icebluewolf@users.noreply.github.com> --------- Signed-off-by: Ice Wolfy <44532864+Icebluewolf@users.noreply.github.com> Co-authored-by: Lala Sabathil <lala@pycord.dev> Co-authored-by: Paillat <paillat@pycord.dev>
1 parent eb6d361 commit 2d762d6

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ These changes are available on the `master` branch, but have not yet been releas
1414

1515
- Added `Member.vr_status` property.
1616
([#3328](https://github.com/Pycord-Development/pycord/pull/3328))
17+
- Added `SlashCommandGroup.add_command`.
18+
([#3346](https://github.com/Pycord-Development/pycord/pull/3346))
1719

1820
### Changed
1921

discord/commands/core.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,9 +1392,22 @@ def to_dict(self) -> dict:
13921392
return as_dict
13931393

13941394
def add_command(self, command: SlashCommand | SlashCommandGroup) -> None:
1395+
"""Adds a :class:`.SlashCommand` or :class:`.SlashCommandGroup` as a subcommand.
1396+
1397+
This is usually not called, instead the :meth:`command` or
1398+
other shortcut decorators are used instead.
1399+
1400+
.. versionadded:: 2.9
1401+
1402+
Parameters
1403+
----------
1404+
command: Union[:class:`.SlashCommand`, :class:`.SlashCommandGroup`]
1405+
The command to add.
1406+
"""
13951407
if command.cog is None and self.cog is not None:
13961408
command.cog = self.cog
13971409

1410+
command.parent = self
13981411
self.subcommands.append(command)
13991412

14001413
def command(
@@ -1410,7 +1423,7 @@ def command(
14101423
"""
14111424

14121425
def wrap(func) -> T:
1413-
command = cls(func, parent=self, **kwargs)
1426+
command = cls(func, **kwargs)
14141427
self.add_command(command)
14151428
return command
14161429

@@ -1508,7 +1521,6 @@ def inner(cls: type[SlashCommandGroup]) -> SlashCommandGroup:
15081521
else "No description provided"
15091522
),
15101523
guild_ids=guild_ids,
1511-
parent=self,
15121524
)
15131525
self.add_command(group)
15141526
return group

0 commit comments

Comments
 (0)