mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
parent
d774b4ac7a
commit
66c48c2d0e
@ -682,6 +682,18 @@ class Command(Generic[GroupT, P, T]):
|
|||||||
if param.autocomplete is None:
|
if param.autocomplete is None:
|
||||||
raise CommandSignatureMismatch(self)
|
raise CommandSignatureMismatch(self)
|
||||||
|
|
||||||
|
predicates = getattr(param.autocomplete, '__discord_app_commands_checks__', [])
|
||||||
|
if predicates:
|
||||||
|
try:
|
||||||
|
if not await async_all(f(interaction) for f in predicates):
|
||||||
|
if not interaction.response.is_done():
|
||||||
|
await interaction.response.autocomplete([])
|
||||||
|
return
|
||||||
|
except Exception:
|
||||||
|
if not interaction.response.is_done():
|
||||||
|
await interaction.response.autocomplete([])
|
||||||
|
return
|
||||||
|
|
||||||
if param.autocomplete.requires_binding:
|
if param.autocomplete.requires_binding:
|
||||||
binding = param.autocomplete.binding or self.binding
|
binding = param.autocomplete.binding or self.binding
|
||||||
if binding is not None:
|
if binding is not None:
|
||||||
@ -791,6 +803,10 @@ class Command(Generic[GroupT, P, T]):
|
|||||||
:attr:`.Interaction.namespace` will give a :class:`Namespace` object with those
|
:attr:`.Interaction.namespace` will give a :class:`Namespace` object with those
|
||||||
values.
|
values.
|
||||||
|
|
||||||
|
Parent :func:`checks <check>` are ignored within an autocomplete. However, checks can be added
|
||||||
|
to the autocomplete callback and the ones added will be called. If the checks fail for any reason
|
||||||
|
then an empty list is sent as the interaction response.
|
||||||
|
|
||||||
The coroutine decorator **must** return a list of :class:`~discord.app_commands.Choice` objects.
|
The coroutine decorator **must** return a list of :class:`~discord.app_commands.Choice` objects.
|
||||||
Only up to 25 objects are supported.
|
Only up to 25 objects are supported.
|
||||||
|
|
||||||
@ -1735,6 +1751,10 @@ def autocomplete(**parameters: AutocompleteCallback[GroupT, ChoiceT]) -> Callabl
|
|||||||
Autocomplete is only supported on types that have :class:`str`, :class:`int`, or :class:`float`
|
Autocomplete is only supported on types that have :class:`str`, :class:`int`, or :class:`float`
|
||||||
values.
|
values.
|
||||||
|
|
||||||
|
:func:`Checks <check>` are supported, however they must be attached to the autocomplete
|
||||||
|
callback in order to work. Checks attached to the command are ignored when invoking the autocomplete
|
||||||
|
callback.
|
||||||
|
|
||||||
For more information, see the :meth:`Command.autocomplete` documentation.
|
For more information, see the :meth:`Command.autocomplete` documentation.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user