discord-interactions.py

autocomplete_handler

Function

Marks a function as the autocomplete of a command.

from discord_interactions.slash import autocomplete_handler

Signature

def autocomplete_handler(    command: str | None = None,    option: str | None = None,) -> Callable

Parameters

NameTypeDefaultDescription
commandstr | NoneNone
optionstr | NoneNone

Returns

Callable

Details

Example:

@autocomplete_handler(command="search", option="query")async def search_autocomplete(ctx: AutocompleteContext):    results = await search_index(ctx.value)    return [(r.title, r.id) for r in results]

Type a name: create_button, ModalBuilder, cooldown.