Implement a least breaking approach to slash commands (#39)

* Most slash command support completed, needs some debugging (and reindent)

* Implement a ctx.send helper for slash commands

* Add group command support

* Add Option converter, fix default optional, fix help command

* Add client.setup and move readying commands to that

* Implement _FakeSlashMessage.from_interaction

* Rename normmal_command to message_command

* Add docs for added params

* Add slash_command_guilds to bot and decos

* Fix merge conflict

* Remove name from commands.Option, wasn't used

* Move slash command processing to BotBase.process_slash_commands

* Create slash_only.py

Basic example for slash commands

* Create slash_and_message.py

Basic example for mixed commands

* Fix slash_command and normal_command bools

* Add some basic error handling for registration

* Fixed converter upload errors

* Fix some logic and make an actual example

* Thanks Safety Jim

* docstrings, *args, and error changes

* Add proper literal support

* Add basic documentation on slash commands

* Fix non-slash command interactions

* Fix ctx.reply in slash command context

* Fix typing on Context.reply

* Fix multiple optional argument sorting

* Update ctx.message docs to mention error instead of warning

* Move slash command creation to BotBase

* Fix code style issues with Black

* Rearrange some stuff and add flag support

* Change some errors and fix interaction.channel fixing

* Fix slash command quoting for *args

Co-authored-by: iDutchy <42503862+iDutchy@users.noreply.github.com>
Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
This commit is contained in:
Gnome!
2021-09-19 00:28:11 +01:00
committed by GitHub
parent 75a23351c4
commit 1957fa6011
14 changed files with 662 additions and 39 deletions

View File

@ -61,6 +61,13 @@ the name to something other than the function would be as simple as doing this:
async def _list(ctx, arg):
pass
Slash Commands
--------------
Slash Commands can be enabled in the :class:`.Bot` constructor or :class:`.Command` constructor, using
``slash_commands=True`` or ``slash_command=True`` respectfully. All features of the commands extension
should work with these options enabled, however many will not have direct discord counterparts and therefore
will be subsituted for supported versions when uploaded to discord.
Parameters
------------
@ -179,6 +186,11 @@ know how the command was executed. It contains a lot of useful information:
The context implements the :class:`abc.Messageable` interface, so anything you can do on a :class:`abc.Messageable` you
can do on the :class:`~ext.commands.Context`.
.. warning::
:attr:`.Context.message` will be fake if in a slash command, it is not
recommended to access if :attr:`.Context.interaction` is not None as most
methods will error due to the message not actually existing.
Converters
------------