Skip to content

AutocompleteInteraction

AutocompleteInteraction ⇐ Interaction

Represents an interaction with an autocomplete component.

Kind: global class
Extends: Interaction

new AutocompleteInteraction([data], guildId, client)

Constructs a new instance of the class.

ParamTypeDescription
[data]ObjectThe data object to initialize the instance with.
guildIdstringThe ID of the guild associated with the instance.
clientClientThe client instance associated with the instance.

autocompleteInteraction.getFocused() ⇒

Retrieves the focused option from the data object.

Kind: instance method of AutocompleteInteraction
Returns: The value of the focused option, or null if no option is focused or if the value is not available.

autocompleteInteraction.respond(choices) ⇒ Promise

Sends a response to an autocomplete interaction with the provided choices.

Kind: instance method of AutocompleteInteraction
Returns: Promise - A promise that resolves when the response is sent.

ParamTypeDescription
choicesArrayAn array of choices for the autocomplete interaction.

AutocompleteInteraction.transformChoices(choices) ⇒ Object

Transforms the given choices object into a new object with the name and value properties.

Kind: static method of AutocompleteInteraction
Returns: Object - - The transformed choices object with name and value properties.
Throws:

  • RangeError - If the length of the name property is less than 1 or greater than 100.
ParamTypeDescription
choicesObjectThe choices object to transform.