AutocompleteHandler
Base class for a Discord autocomplete handler.
Pass the command route(s) from the generated registry as the generic, the same string(s) as @AutocompleteRoute@AutocompleteRoute. Branch on the focused field with this.matchthis.match, read already-entered sibling options with this.optionsthis.options, and find which command fired with this.routethis.route.
abstract class AutocompleteHandler<
Route extends keyof SlashOptionRegistry,
Cache extends CacheType = "cached"
> extends BaseHandler<AutocompleteInteraction<Cache>>abstract class AutocompleteHandler<
Route extends keyof SlashOptionRegistry,
Cache extends CacheType = "cached"
> extends BaseHandler<AutocompleteInteraction<Cache>>Member visibility
Filter class members by access level.
AutocompleteHandler(
event: AutocompleteInteraction<Cache>,
core: Core,
dispatch?: DispatchContext
)AutocompleteHandler(
event: AutocompleteInteraction<Cache>,
core: Core,
dispatch?: DispatchContext
)Route
One or more route keys from SlashOptionRegistrySlashOptionRegistry, e.g. 'search''search' or 'search' | 'find''search' | 'find'.
Route extends keyof SlashOptionRegistryRoute extends keyof SlashOptionRegistryCache
The interaction cache state, 'cached''cached' by default.
protected focused: FocusedField<Route>protected focused: FocusedField<Route>protected options: AutocompleteOptions<Route>protected options: AutocompleteOptions<Route>protected route: Routeprotected route: RouteRun the arm for the focused field. An autocomplete always dispatches by which field is focused, so match is how you read it. There is no single-field shortcut the way slash/component handlers have one.
Provide one arm per autocompletable field across the registered commands, keyed by field name. Each arm receives the focused partial value and a respondrespond typed to that field's choice value. The arms must cover every autocompletable field, a missing field or an unknown key is a compile error. A focused field with no arm, only reachable from a stale-deployed command, throws at runtime.
protected async match<Ret>(
arms: FocusedArms<Route, Ret>
): Promise<Ret>protected async match<Ret>(
arms: FocusedArms<Route, Ret>
): Promise<Ret>armsOne handler per autocompletable field, keyed by field name.
Send autocomplete suggestions, callback type 8. Prefer matchmatch, which restricts each field's choices to its declared type.
protected async respond(
choices: readonly ApplicationCommandOptionChoiceData[]
): Promise<void>protected async respond(
choices: readonly ApplicationCommandOptionChoiceData[]
): Promise<void>