Skip to content

Commit 2bbf063

Browse files
Document slash command group and context menus
1 parent 26c73da commit 2bbf063

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

discord/commands/commands.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,33 @@ def decor(func):
612612
return decor
613613

614614
class SlashCommandGroup(ApplicationCommand, Option):
615+
r"""A class that implements the protocol for a slash command group.
616+
617+
These can be created manually, but they should be created via the
618+
decorator or functional interface.
619+
620+
Attributes
621+
-----------
622+
name: :class:`str`
623+
The name of the command.
624+
description: Optional[:class:`str`]
625+
The description for the command.
626+
guild_ids: Optional[List[:class:`int`]]
627+
The ids of the guilds where this command will be registered.
628+
parent_group: Optional[:class:`SlashCommandGroup`]
629+
The parent group of this group.
630+
subcommands: List[Union[:class:`SlashCommand`, :class:`SlashCommandGroup`]]
631+
The list of all subcommands under this group.
632+
cog: Optional[:class:`Cog`]
633+
The cog that this command belongs to. ``None`` if there isn't one.
634+
checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
635+
A list of predicates that verifies if the command could be executed
636+
with the given :class:`.ApplicationContext` as the sole parameter. If an exception
637+
is necessary to be thrown to signal failure, then one inherited from
638+
:exc:`.CommandError` should be used. Note that if the checks fail then
639+
:exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
640+
event.
641+
"""
615642
type = 1
616643

617644
def __new__(cls, *args, **kwargs) -> SlashCommandGroup:
@@ -680,6 +707,29 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
680707
await command.invoke(ctx)
681708

682709
class ContextMenuCommand(ApplicationCommand):
710+
r"""A class that implements the protocol for context menu commands.
711+
712+
These are not created manually, instead they are created via the
713+
decorator or functional interface.
714+
715+
Attributes
716+
-----------
717+
name: :class:`str`
718+
The name of the command.
719+
callback: :ref:`coroutine <coroutine>`
720+
The coroutine that is executed when the command is called.
721+
guild_ids: Optional[List[:class:`int`]]
722+
The ids of the guilds where this command will be registered.
723+
cog: Optional[:class:`Cog`]
724+
The cog that this command belongs to. ``None`` if there isn't one.
725+
checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
726+
A list of predicates that verifies if the command could be executed
727+
with the given :class:`.ApplicationContext` as the sole parameter. If an exception
728+
is necessary to be thrown to signal failure, then one inherited from
729+
:exc:`.CommandError` should be used. Note that if the checks fail then
730+
:exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
731+
event.
732+
"""
683733
def __new__(cls, *args, **kwargs) -> ContextMenuCommand:
684734
self = super().__new__(cls)
685735

@@ -693,7 +743,7 @@ def __init__(self, func: Callable, *args, **kwargs) -> None:
693743

694744
self.guild_ids: Optional[List[int]] = kwargs.get("guild_ids", None)
695745

696-
# Discord API doesn't support setting descriptions for User commands
746+
# Discord API doesn't support setting descriptions for context menu commands
697747
# so it must be empty
698748
self.description = ""
699749
self.name: str = kwargs.pop("name", func.__name__)

0 commit comments

Comments
 (0)