Implement some built in checks for app_commands

A lot of these implementations are adapted from the equivalent
ext.commands checks. These only implement the common ones that could
not solely be done by Discord in the future.
This commit is contained in:
Rapptz
2022-03-28 15:55:29 -04:00
parent 8524bfb54d
commit 74b5e0ceb1
4 changed files with 400 additions and 3 deletions

View File

@ -468,15 +468,32 @@ Decorators
.. autofunction:: discord.app_commands.choices
:decorator:
.. autofunction:: discord.app_commands.check
:decorator:
.. autofunction:: discord.app_commands.autocomplete
:decorator:
.. autofunction:: discord.app_commands.guilds
:decorator:
Checks
+++++++
.. autofunction:: discord.app_commands.check
:decorator:
.. autofunction:: discord.app_commands.checks.has_role
:decorator:
.. autofunction:: discord.app_commands.checks.has_any_role
:decorator:
.. autofunction:: discord.app_commands.checks.has_permissions
:decorator:
.. autofunction:: discord.app_commands.checks.bot_has_permissions
:decorator:
Namespace
~~~~~~~~~~
@ -527,6 +544,21 @@ Exceptions
.. autoexception:: discord.app_commands.CheckFailure
:members:
.. autoexception:: discord.app_commands.NoPrivateMessage
:members:
.. autoexception:: discord.app_commands.MissingRole
:members:
.. autoexception:: discord.app_commands.MissingAnyRole
:members:
.. autoexception:: discord.app_commands.MissingPermissions
:members:
.. autoexception:: discord.app_commands.BotMissingPermissions
:members:
.. autoexception:: discord.app_commands.CommandAlreadyRegistered
:members:
@ -546,6 +578,11 @@ Exception Hierarchy
- :exc:`~discord.app_commands.CommandInvokeError`
- :exc:`~discord.app_commands.TransformerError`
- :exc:`~discord.app_commands.CheckFailure`
- :exc:`~discord.app_commands.NoPrivateMessage`
- :exc:`~discord.app_commands.MissingRole`
- :exc:`~discord.app_commands.MissingAnyRole`
- :exc:`~discord.app_commands.MissingPermissions`
- :exc:`~discord.app_commands.BotMissingPermissions`
- :exc:`~discord.app_commands.CommandAlreadyRegistered`
- :exc:`~discord.app_commands.CommandSignatureMismatch`
- :exc:`~discord.app_commands.CommandNotFound`