[commands] Add initial implementation of hybrid commands

Hybrid commands allow a regular command to also double as a slash
command, assuming it meets the subset required to function.
This commit is contained in:
Rapptz
2022-04-10 17:14:38 -04:00
parent 151806ec94
commit 840eb577d4
10 changed files with 919 additions and 28 deletions

View File

@ -114,6 +114,13 @@ Decorators
.. autofunction:: discord.ext.commands.group
:decorator:
.. autofunction:: discord.ext.commands.hybrid_command
:decorator:
.. autofunction:: discord.ext.commands.hybrid_group
:decorator:
Command
~~~~~~~~~
@ -173,6 +180,51 @@ GroupMixin
.. automethod:: GroupMixin.group(*args, **kwargs)
:decorator:
HybridCommand
~~~~~~~~~~~~~~
.. attributetable:: discord.ext.commands.HybridCommand
.. autoclass:: discord.ext.commands.HybridCommand
:members:
:special-members: __call__
:exclude-members: after_invoke, before_invoke, error
.. automethod:: HybridCommand.after_invoke()
:decorator:
.. automethod:: HybridCommand.before_invoke()
:decorator:
.. automethod:: HybridCommand.error()
:decorator:
HybridGroup
~~~~~~~~~~~~
.. attributetable:: discord.ext.commands.HybridGroup
.. autoclass:: discord.ext.commands.HybridGroup
:members:
:inherited-members:
:exclude-members: after_invoke, before_invoke, command, error, group
.. automethod:: HybridGroup.after_invoke()
:decorator:
.. automethod:: HybridGroup.before_invoke()
:decorator:
.. automethod:: HybridGroup.command(*args, **kwargs)
:decorator:
.. automethod:: HybridGroup.error()
:decorator:
.. automethod:: HybridGroup.group(*args, **kwargs)
:decorator:
.. _ext_commands_api_cogs:
Cogs
@ -631,6 +683,9 @@ Exceptions
.. autoexception:: discord.ext.commands.CommandRegistrationError
:members:
.. autoexception:: discord.ext.commands.HybridCommandError
:members:
Exception Hierarchy
~~~~~~~~~~~~~~~~~~~~~
@ -687,6 +742,7 @@ Exception Hierarchy
- :exc:`~.commands.CommandInvokeError`
- :exc:`~.commands.CommandOnCooldown`
- :exc:`~.commands.MaxConcurrencyReached`
- :exc:`~.commands.HybridCommandError`
- :exc:`~.commands.ExtensionError`
- :exc:`~.commands.ExtensionAlreadyLoaded`
- :exc:`~.commands.ExtensionNotLoaded`