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>>
implements Handlerabstract class AutocompleteHandler<
Route extends keyof SlashOptionRegistry,
Cache extends CacheType = "cached"
>
extends BaseHandler<AutocompleteInteraction<Cache>>
implements HandlerMember visibility
Filter class members by access level.
AutocompleteHandler(
event: AutocompleteInteraction<Cache>,
core: Core
)AutocompleteHandler(
event: AutocompleteInteraction<Cache>,
core: Core
)Route
One or more route keys from SlashOptionRegistry, 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>The already-entered options on this command, restricted to the kinds Discord resolves during autocomplete (string, integer, number, boolean) with every read nullable, since a sibling is partial while the user types the focused field. Read the focused field from this.focusedthis.focused, not here.
protected options: AutocompleteOptions<Route>protected options: AutocompleteOptions<Route>protected route: Routeprotected route: RouteRun the arm for the focused field.
Provide one arm per autocompletable field across the registered commands. Each arm receives the focused partial value and a respondrespond pinned to that field's choice value type. A missing arm is a compile error. A focused field with no arm, only reachable from a stale-deployed command, throws.
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.