diff --git a/docs/conf.py b/docs/conf.py index 2f4e23587..7cef35d9a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -248,7 +248,7 @@ intersphinx_mapping = { # This allows to create links to d.py docs with # :dpy_docs:`link text ` extlinks = { - "dpy_docs": (f"{dpy_docs_url}/%s", None), + "dpy_docs": (f"{dpy_docs_url}%s", None), "issue": ("https://github.com/Cog-Creators/Red-DiscordBot/issues/%s", "#%s"), "ghuser": ("https://github.com/%s", "@%s"), } diff --git a/docs/guide_slash_and_interactions.rst b/docs/guide_slash_and_interactions.rst index 15df9abc4..342209477 100644 --- a/docs/guide_slash_and_interactions.rst +++ b/docs/guide_slash_and_interactions.rst @@ -17,7 +17,7 @@ Getting Started --------------- To start off, we will have to import some additional modules to our cog file. -We will be using the :class:`redbot.core.app_commands` module to create our slash commands. +We will be using the ``redbot.core.app_commands`` module to create our slash commands. Once we have imported the module, we can start creating our slash commands in our cog class. For this example we will use a basic hello world command. @@ -49,7 +49,7 @@ Below we will go over some of the different stuff you can do with slash commands Decorators ---------- Just like with text commands, we can use decorators to modify the behaviour of our slash commands. -For example, we can use the :func:`app_commands.guild_only` decorator to make our slash command only work in guilds. +For example, we can use the `app_commands.guild_only() ` decorator to make our slash command only work in guilds. .. code-block:: python @@ -66,7 +66,7 @@ For example, we can use the :func:`app_commands.guild_only` decorator to make ou async def hello(self, interaction: discord.Interaction): await interaction.response.send_message("Hello World!", ephemeral=True) -One of the more useful decorators is the :func:`app.commands.choices` decorator. +One of the more useful decorators is the `app_commands.choices() ` decorator. This decorator allows us to specify a list of choices for a specific argument. This is useful for arguments that have a limited number of options. For example, we can use this to create a command that allows us to choose between two different colors. @@ -85,15 +85,16 @@ For example, we can use this to create a command that allows us to choose betwee app_commands.Choice(name="Red", value="red"), app_commands.Choice(name="Blue", value="blue"), ]) - async def color(self, interaction: discord.Interaction, color: Color): - await interaction.response.send_message(f"Your color is {color}", ephemeral=True) + async def color(self, interaction: discord.Interaction, color: app_commands.Choice[str]): + await interaction.response.send_message(f"Your color is {color.value}", ephemeral=True) -The user will be shown the ``name`` of the choice, and the argument will be passed the -``value`` associated with that choice. This allows user-facing names to be prettier than -what is actually processed by the command. +The user will be shown the ``name`` of the choice, and the argument will be passed a +`app_commands.Choice ` object with the ``name`` and ``value`` associated with that choice. +This allows user-facing names to be prettier than what is actually processed by the command. Alternatively, ``Literal`` can be used if the argument does not need a different -user-facing label. +user-facing label. When done this way, the resulting parameter will be one of +the literal values listed. .. code-block:: python @@ -109,8 +110,8 @@ user-facing label. async def color(self, interaction: discord.Interaction, color: Literal["Red", "Blue"]): await interaction.response.send_message(f"Your color is {color}", ephemeral=True) -Finally, an ``Enum`` subclass can be used to specify choices. When done this way, the -resulting parameter will be an instance of that enum, rather than the ``value``. +Finally, an `enum.Enum` subclass can be used to specify choices. When done this way, the +resulting parameter will be an instance of that enum, rather than `app_commands.Choice `. .. code-block:: python @@ -130,7 +131,7 @@ resulting parameter will be an instance of that enum, rather than the ``value``. async def color(self, interaction: discord.Interaction, color: Color): await interaction.response.send_message(f"Your color is {color.value}", ephemeral=True) -Check out the full reference of decorators on Discord.py's documentation `here `__. +Check out :dpy_docs:`the full reference of decorators at Discord.py's documentation `. Groups & Subcommands