Application Command Manager (#5992)

Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
This commit is contained in:
Flame442
2023-03-20 16:31:37 -04:00
committed by GitHub
parent b2e17775a0
commit f06b734e15
8 changed files with 974 additions and 4 deletions

View File

@@ -4045,6 +4045,152 @@ This is the recommended method for shutting down the bot.
**Arguments:**
- ``[silently]`` - Whether to skip sending the shutdown message. Defaults to False.
.. _core-command-slash:
^^^^^
slash
^^^^^
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]slash
**Description**
Base command for managing what application commands are able to be used on Red.
.. _core-command-slash-disable:
"""""""""""""
slash disable
"""""""""""""
**Syntax**
.. code-block:: none
[p]slash disable <command_name> [command_type]
**Description**
Marks an application command as being disabled, preventing it from being added to the bot.
See commands available to disable with ``[p]slash list``. This command does NOT sync the
enabled commands with Discord, that must be done manually with ``[p]slash sync`` for
commands to appear in users' clients.
**Arguments:**
- ``<command_name>`` - The command name to disable. Only the top level name of a group command should be used.
- ``[command_type]`` - What type of application command to disable. Must be one of ``slash``, ``message``, or ``user``. Defaults to ``slash``.
.. _core-command-slash-disablecog:
""""""""""""""""
slash disablecog
""""""""""""""""
**Syntax**
.. code-block:: none
[p]slash disablecog <cog_name>
**Description**
Marks all application commands in a cog as being disabled, preventing them from being
added to the bot. See a list of cogs with application commands with ``[p]slash list``.
This command does NOT sync the enabled commands with Discord, that must be done manually
with ``[p]slash sync`` for commands to appear in users' clients.
**Arguments:**
- ``<cog_name>`` - The cog to disable commands from. This argument is case sensitive.
.. _core-command-slash-enable:
""""""""""""
slash enable
""""""""""""
**Syntax**
.. code-block:: none
[p]slash enable <command_name> [command_type]
**Description**
Marks an application command as being enabled, allowing it to be added to the bot.
See commands available to enable with ``[p]slash list``. This command does NOT sync the
enabled commands with Discord, that must be done manually with ``[p]slash sync`` for
commands to appear in users' clients.
**Arguments:**
- ``<command_name>`` - The command name to enable. Only the top level name of a group command should be used.
- ``[command_type]`` - What type of application command to enable. Must be one of ``slash``, ``message``, or ``user``. Defaults to ``slash``.
.. _core-command-slash-enablecog:
"""""""""""""""
slash enablecog
"""""""""""""""
**Syntax**
.. code-block:: none
[p]slash enablecog <cog_name>
**Description**
Marks all application commands in a cog as being enabled, allowing them to be
added to the bot. See a list of cogs with application commands with ``[p]slash list``.
This command does NOT sync the enabled commands with Discord, that must be done manually
with ``[p]slash sync`` for commands to appear in users' clients.
**Arguments:**
- ``<cog_name>`` - The cog to enable commands from. This argument is case sensitive.
.. _core-command-slash-list:
""""""""""
slash list
""""""""""
**Syntax**
.. code-block:: none
[p]slash list
**Description**
List the slash commands the bot can see, and whether or not they are enabled.
This command shows the state that will be changed to when ``[p]slash sync`` is run.
.. _core-command-slash-sync:
""""""""""
slash sync
""""""""""
**Syntax**
.. code-block:: none
[p]slash sync [guild]
**Description**
Syncs the slash settings to discord.
Settings from ``[p]slash list`` will be synced with discord, changing what commands appear for users.
This should be run sparingly, make all necessary changes before running this command.
**Arguments:**
- ``[guild]`` - If provided, syncs commands for that guild. Otherwise, syncs global commands.
.. _core-command-traceback:
^^^^^^^^^

21
docs/framework_tree.rst Normal file
View File

@@ -0,0 +1,21 @@
.. tree module docs
====
Tree
====
Red uses a subclass of discord.py's ``CommandTree`` object in order to allow Cog Creators to add application commands to their cogs without worrying about the command count limit and to support caching ``AppCommand`` objects. When an app command is added to the bot's tree, it will not show up in ``tree.get_commands`` or other similar methods unless the command is "enabled" with ``[p]slash enable`` (similar to "load"ing a cog) and ``tree.red_check_enabled`` has been run since the command was added to the tree.
.. note::
If you are adding app commands to the tree during load time, the loading process will call ``tree.red_check_enabled`` for your cog and its app commands. If you are adding app commands to the bot **outside of load time**, a call to ``tree.red_check_enabled`` after adding the commands is required to ensure the commands will appear properly.
If application commands from your cog show up in ``[p]slash list`` as enabled from an ``(unknown)`` cog and disabled from your cog at the same time, you did not follow the instructions above. You must manually call ``tree.red_check_enabled`` **after** adding the commands to the tree.
.. automodule:: redbot.core.tree
RedTree
^^^^^^^
.. autoclass:: RedTree
:members:

View File

@@ -77,6 +77,7 @@ Welcome to Red - Discord Bot's documentation!
framework_i18n
framework_modlog
framework_rpc
framework_tree
framework_utils
version_guarantees