diff --git a/changelog/1112.doc.rst b/changelog/1112.doc.rst new file mode 100644 index 0000000000..e510f78951 --- /dev/null +++ b/changelog/1112.doc.rst @@ -0,0 +1 @@ +Document the :class:`.Option` attributes, the ``description`` and ``options`` properties for :class:`.ext.commands.InvokableSlashCommand` and the ``description`` and ``body`` properties for :class:`.ext.commands.SubCommand`. diff --git a/disnake/app_commands.py b/disnake/app_commands.py index 17c3fd713a..a6a58fe188 100644 --- a/disnake/app_commands.py +++ b/disnake/app_commands.py @@ -198,6 +198,40 @@ class Option: .. versionadded:: 2.6 + max_length: :class:`int` + The maximum length for this option if this is a string option. + + .. versionadded:: 2.6 + + Attributes + ---------- + name: :class:`str` + The option's name. + description: :class:`str` + The option's description. + type: :class:`OptionType` + The option type, e.g. :class:`OptionType.user`. + required: :class:`bool` + Whether this option is required. + choices: List[:class:`OptionChoice`] + The list of option choices. + options: List[:class:`Option`] + The list of sub options. Normally you don't have to specify it directly, + instead consider using ``@main_cmd.sub_command`` or ``@main_cmd.sub_command_group`` decorators. + channel_types: List[:class:`ChannelType`] + The list of channel types that your option supports, if the type is :class:`OptionType.channel`. + By default, it supports all channel types. + autocomplete: :class:`bool` + Whether this option can be autocompleted. + min_value: Union[:class:`int`, :class:`float`] + The minimum value permitted. + max_value: Union[:class:`int`, :class:`float`] + The maximum value permitted. + min_length: :class:`int` + The minimum length for this option if this is a string option. + + .. versionadded:: 2.6 + max_length: :class:`int` The maximum length for this option if this is a string option. diff --git a/disnake/ext/commands/slash_core.py b/disnake/ext/commands/slash_core.py index 4652c552f8..a23cf86bd3 100644 --- a/disnake/ext/commands/slash_core.py +++ b/disnake/ext/commands/slash_core.py @@ -332,10 +332,12 @@ def parents( @property def description(self) -> str: + """:class:`str`: The slash sub command's description. Shorthand for :attr:`self.body.description <.Option.description>`.""" return self.body.description @property def body(self) -> Option: + """:class:`.Option`: The API representation for this slash sub command. Shorthand for :attr:`.SubCommand.option`""" return self.option async def _call_autocompleter( @@ -508,10 +510,12 @@ def _ensure_assignment_on_copy(self, other: SlashCommandT) -> SlashCommandT: @property def description(self) -> str: + """:class:`str`: The slash command's description. Shorthand for :attr:`self.body.description <.SlashCommand.description>`.""" return self.body.description @property def options(self) -> List[Option]: + """List[:class:`.Option`]: The list of options the slash command has. Shorthand for :attr:`self.body.options <.SlashCommand.options>`.""" return self.body.options def sub_command( diff --git a/docs/api/app_commands.rst b/docs/api/app_commands.rst index 1d26bee539..a55e3670ab 100644 --- a/docs/api/app_commands.rst +++ b/docs/api/app_commands.rst @@ -97,7 +97,7 @@ Option .. attributetable:: Option -.. autoclass:: Option() +.. autoclass:: Option :members: OptionChoice