AutocompleteHelper
Represents an autocomplete response for Discord API application commands.
Defined in: utils/Autocomplete.ts:23
Represents an autocomplete response for Discord API application commands. Manages a collection of command option choices and filters them based on user input.
This is because Typescript cannot infer the type of T from the constructor argument value somehow.
Example
Type Parameters
T
T extends string | number = string | number
The type of choice values, must be either string or number.
Constructors
Constructor
new AutocompleteHelper<
T>(value,user?):AutocompleteHelper<T>
Defined in: utils/Autocomplete.ts:32
Parameters
value
T
The current input value from the user to filter against.
user?
APIUser
The user object, used to provide localized results if available.
Returns
AutocompleteHelper<T>
Accessors
choices
Get Signature
get choices():
APIApplicationCommandOptionChoice<T>[]
Defined in: utils/Autocomplete.ts:38
The current array of choices stored in the helper.
Returns
APIApplicationCommandOptionChoice<T>[]
Methods
addChoices()
addChoices(…
choices):AutocompleteHelper<T>
Defined in: utils/Autocomplete.ts:43
Adds one or more choices to the existing list.
Parameters
choices
…APIApplicationCommandOptionChoice<T>[]
Returns
AutocompleteHelper<T>
clear()
clear():
AutocompleteHelper<T>
Defined in: utils/Autocomplete.ts:55
Removes all choices from the helper.
Returns
AutocompleteHelper<T>
response()
response(
filterFields?):APIApplicationCommandOptionChoice<T>[]
Defined in: utils/Autocomplete.ts:97
Filters choices based on the value provided in the constructor.
Parameters
filterFields?
(keyof APIApplicationCommandOptionChoice<T>)[] = []
An array of fields to filter by. Defaults to an empty array.
Returns
APIApplicationCommandOptionChoice<T>[]
An array of filtered choices.
If filterFields is omitted, it will be filtered by all fields.
setChoices()
setChoices(…
choices):AutocompleteHelper<T>
Defined in: utils/Autocomplete.ts:49
Overwrites the current list of choices with a new set.
Parameters
choices
…APIApplicationCommandOptionChoice<T>[]
Returns
AutocompleteHelper<T>