From 8b0be066e14b83072cbb6248ee6d6467aa5f505b Mon Sep 17 00:00:00 2001 From: Gnome Date: Sat, 25 Sep 2021 18:36:19 +0100 Subject: [PATCH] Improve docs for slash commands further --- docs/ext/commands/slash-commands.rst | 8 ++++--- docs/faq.rst | 31 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/docs/ext/commands/slash-commands.rst b/docs/ext/commands/slash-commands.rst index a30e47e1..db0b89b6 100644 --- a/docs/ext/commands/slash-commands.rst +++ b/docs/ext/commands/slash-commands.rst @@ -10,12 +10,14 @@ Slash Commands are currently supported in enhanced-discord.py using a system on This system is very simple to use, and can be enabled via :attr:`.Bot.slash_commands` globally, or only for specific commands via :attr:`.Command.slash_command`. -There is also the parameter ``slash_command_guilds`` which can be passed to either :class:`.Bot` or the command decorator -in order to only upload the commands as guild commands to these specific guild IDs, however this should only be used for -testing or small (<10 guilds) bots. +There is also the parameter ``slash_command_guilds`` which can be passed to either :class:`.Bot` or the command +decorator in order to only upload the commands as guild commands to these specific guild IDs, however this +should only be used for testing or small (<10 guilds) bots. If you want to add option descriptions to your commands, you should use :class:`.Option` +For troubleshooting, see the :ref:`FAQ ` + .. admonition:: Slash Command Only For parts of the docs specific to slash commands, look for this box! diff --git a/docs/faq.rst b/docs/faq.rst index 3f46d2a9..556bb34f 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -410,3 +410,34 @@ Example: :: await ctx.send(f'Pushing to {remote} {branch}') This could then be used as ``?git push origin master``. + +How do I make slash commands? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See :doc:`/ext/commands/slash-commands` + +My slash commands aren't showing up! +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. _ext_commands_slash_command_troubleshooting: + +You need to invite your bot with the ``application.commands`` scope on each guild and +you need the :attr:`Permissions.use_slash_commands` permission in order to see slash commands. + +.. image:: /images/discord_oauth2_slash_scope.png + :alt: The scopes checkbox with "bot" and "applications.commands" ticked. + +Global slash commands (created by not specifying :attr:`~ext.commands.Bot.slash_command_guilds`) will also take up an +hour to refresh on discord's end, so it is recommended to set :attr:`~ext.commands.Bot.slash_command_guilds` for development. + +If none of this works, make sure you are actually running enhanced-discord.py by doing ``print(bot.slash_commands)`` + +My bot won't start after enabling slash commands! +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This means some of your command metadata is invalid for slash commands. +Make sure your command names and option names are lowercase, and they have to match the regex ``^[\w-]{1,32}$`` + +If you cannot figure out the problem, you should disable slash commands globally (:attr:`~ext.commands.Bot.slash_commands`\=False) +then go through commands, enabling them specifically with :attr:`~.commands.Command.slash_command`\=True until it +errors, then you can debug the problem with that command specifically.