Skip to content

AutocompleteInteraction

Interface: AutocompleteInteraction<Context>

Section titled “Interface: AutocompleteInteraction<Context>”

Defined in: interactions/AutocompleteInteraction.ts:13

An autocomplete request for a slash command option. Passed to SlashCommandHandler.executeAutocomplete.

Context extends BaseInteractionContext = BaseInteractionContext

protected _ephemeral: boolean | null = null

Defined in: interactions/BaseInteraction.ts:93

BaseInteraction._ephemeral


protected api: API

Defined in: interactions/BaseInteraction.ts:102

BaseInteraction.api


readonly context: Context

Defined in: interactions/BaseInteraction.ts:97

The Hono interaction context this interaction was created from.

BaseInteraction.context


protected deferred: boolean = false

Defined in: interactions/BaseInteraction.ts:95

BaseInteraction.deferred


readonly fetcher: Fetcher

Defined in: interactions/BaseInteraction.ts:99

Cache-aware fetcher for resolving Discord entities referenced by this interaction.

BaseInteraction.fetcher


readonly options: CommandInteractionOptionResolver

Defined in: interactions/AutocompleteInteraction.ts:18

Resolver for reading the command’s option values, including the currently-focused option.


protected readonly raw: APIApplicationCommandAutocompleteInteraction

Defined in: interactions/BaseInteraction.ts:90

The raw interaction data

BaseInteraction.raw


protected replied: boolean = false

Defined in: interactions/BaseInteraction.ts:94

BaseInteraction.replied


responded: boolean = false

Defined in: interactions/AutocompleteInteraction.ts:20

Whether respond has already been called for this interaction.


readonly rest: REST

Defined in: interactions/BaseInteraction.ts:92

REST client used to make requests to the Discord API.

BaseInteraction.rest


readonly type: ApplicationCommandAutocomplete

Defined in: interactions/BaseInteraction.ts:88

The interaction’s Discord interaction type.

BaseInteraction.type

get applicationId(): string

Defined in: interactions/BaseInteraction.ts:114

The ID of the application this interaction was sent to.

string

BaseInteraction.applicationId


get appPermissions(): string

Defined in: interactions/BaseInteraction.ts:179

Bitwise set of permissions the app has in the source location of the interaction.

string

BaseInteraction.appPermissions


get channel(): Partial<APIAnnouncementThreadChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIDMChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGroupDMChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildCategoryChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildForumChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildMediaChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildStageVoiceChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildVoiceChannel> & Pick<APIChannel, "id" | "type"> | Partial<APINewsChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIPrivateThreadChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIPublicThreadChannel> & Pick<APIChannel, "id" | "type"> | Partial<APITextChannel> & Pick<APIChannel, "id" | "type"> | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | undefined

Defined in: interactions/BaseInteraction.ts:129

The partial channel object the interaction was sent from, if any. Not cached — see Honocord’s runtime notes.

Partial<APIAnnouncementThreadChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIDMChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGroupDMChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildCategoryChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildForumChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildMediaChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildStageVoiceChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIGuildVoiceChannel> & Pick<APIChannel, "id" | "type"> | Partial<APINewsChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIPrivateThreadChannel> & Pick<APIChannel, "id" | "type"> | Partial<APIPublicThreadChannel> & Pick<APIChannel, "id" | "type"> | Partial<APITextChannel> & Pick<APIChannel, "id" | "type"> | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | never | undefined

BaseInteraction.channel


get channelId(): string | undefined

Defined in: interactions/BaseInteraction.ts:124

The ID of the channel the interaction was sent from, if any.

string | undefined

BaseInteraction.channelId


get commandId(): string

Defined in: interactions/AutocompleteInteraction.ts:33

The invoked command’s ID.

string


get commandName(): string

Defined in: interactions/AutocompleteInteraction.ts:28

The invoked command’s name.

string


get entitlements(): APIEntitlement[]

Defined in: interactions/BaseInteraction.ts:119

Entitlements for the invoking user, for monetized apps.

APIEntitlement[]

BaseInteraction.entitlements


get guild(): APIPartialInteractionGuild | undefined

Defined in: interactions/BaseInteraction.ts:139

The partial guild object the interaction was sent from, if any. Not cached.

APIPartialInteractionGuild | undefined

BaseInteraction.guild


get guildId(): string | undefined

Defined in: interactions/BaseInteraction.ts:134

The ID of the guild the interaction was sent from, if any.

string | undefined

BaseInteraction.guildId


get guildLocale(): Locale | undefined

Defined in: interactions/BaseInteraction.ts:164

The guild’s locale, if sent from a guild.

Locale | undefined

BaseInteraction.guildLocale


get id(): string

Defined in: interactions/BaseInteraction.ts:174

The interaction’s ID.

string

BaseInteraction.id


get locale(): Locale | undefined

Defined in: interactions/BaseInteraction.ts:159

The invoking user’s locale.

Locale | undefined

BaseInteraction.locale


get member(): APIInteractionGuildMember | undefined

Defined in: interactions/BaseInteraction.ts:154

The guild member who triggered the interaction, if sent from a guild.

APIInteractionGuildMember | undefined

BaseInteraction.member


get token(): string

Defined in: interactions/BaseInteraction.ts:169

The interaction token, used to send/edit/delete responses.

string

BaseInteraction.token


get user(): APIUser

Defined in: interactions/BaseInteraction.ts:149

The user who triggered the interaction (resolved from member.user in guilds, user in DMs).

APIUser

BaseInteraction.user


get userId(): string | undefined

Defined in: interactions/BaseInteraction.ts:144

The ID of the user who triggered the interaction.

string | undefined

BaseInteraction.userId


get version(): 1

Defined in: interactions/BaseInteraction.ts:184

Discord’s interaction payload version (always 1).

1

BaseInteraction.version

deferReply(forceEphemeral?): Promise<RESTPostAPIInteractionCallbackWithResponseResult>

Defined in: interactions/BaseInteraction.ts:296

Acknowledges the interaction without sending an initial response, showing a “thinking” state. Use editReply afterwards to send the actual response, within the 15-minute interaction token lifetime.

boolean = true

Whether the eventual response should be ephemeral. Defaults to true.

Promise<RESTPostAPIInteractionCallbackWithResponseResult>

BaseInteraction.deferReply


deferUpdate(): Promise<RESTPostAPIInteractionCallbackWithResponseResult>

Defined in: interactions/BaseInteraction.ts:321

Defers the update of a component interaction.

Promise<RESTPostAPIInteractionCallbackWithResponseResult>

A promise that resolves when the update is deferred

Responding to a component interaction via the deferUpdate() method acknowledges the interaction and resets the message state. This method can be used to suppress the need for further responses, however it’s encouraged to provide meaningful feedback to users via an update() or ephemeral reply() at least.
Once deferUpdate() has been called, future messages can be sent by calling followUp() or edits can be made by calling editReply() on the component interaction.

Example flow:

  1. User clicks a button.
  2. Bot calls deferUpdate() to acknowledge the interaction.
  3. Bot performs some processing.
  4. Bot calls editReply() to update the original message.

BaseInteraction.deferUpdate


deleteReply(messageId?): Promise<void>

Defined in: interactions/BaseInteraction.ts:359

Deletes the original interaction response (or a follow-up message).

string

The message id to delete, defaults to @original

Promise<void>

A promise that resolves when the message is deleted

This is used to delete the original interaction response message or a follow-up message.

BaseInteraction.deleteReply


editReply(options, messageId?): Promise<APIMessage>

Defined in: interactions/BaseInteraction.ts:336

Edits the original interaction response.

string | InteractionResponseCallbackData

The options to edit the message with

string = "@original"

The message id to edit, defaults to @original

Promise<APIMessage>

The edited message

This is used to edit the original interaction response message.

Before using this method, the interaction needs to be replied to first before using this method - with reply, deferReply or update.

BaseInteraction.editReply


followUp(options, forceEphemeral?): Promise<APIMessage>

Defined in: interactions/BaseInteraction.ts:397

Sends a follow-up message to the interaction.

string | InteractionResponseCallbackData

The options to send the follow-up message with

boolean = false

Whether to force the message to be ephemeral

Promise<APIMessage>

The sent follow-up message

This is used to send additional messages after the initial interaction response.

BaseInteraction.followUp


getAppEntitlements(): APIEntitlement[]

Defined in: interactions/BaseInteraction.ts:207

Returns entitlements belonging to this interaction’s application.

APIEntitlement[]

BaseInteraction.getAppEntitlements


guildHavePremium(): boolean

Defined in: interactions/BaseInteraction.ts:212

Whether the guild this interaction was sent from currently has an active, non-expired entitlement.

boolean

BaseInteraction.guildHavePremium


inDM(): this is BaseInteraction<ApplicationCommandAutocomplete, BaseInteractionContext> & { guild: undefined; guild_id: undefined; guild_locale: undefined }

Defined in: interactions/BaseInteraction.ts:202

Type guard narrowing guild_id/guild/guild_locale to undefined when the interaction was sent from a DM.

this is BaseInteraction<ApplicationCommandAutocomplete, BaseInteractionContext> & { guild: undefined; guild_id: undefined; guild_locale: undefined }

BaseInteraction.inDM


inGuild(): this is BaseInteraction<ApplicationCommandAutocomplete, BaseInteractionContext> & { guild: APIPartialInteractionGuild; guild_id: string; guild_locale: Locale }

Defined in: interactions/BaseInteraction.ts:197

Type guard narrowing guild_id/guild/guild_locale to defined when the interaction was sent from a guild.

this is BaseInteraction<ApplicationCommandAutocomplete, BaseInteractionContext> & { guild: APIPartialInteractionGuild; guild_id: string; guild_locale: Locale }

BaseInteraction.inGuild


isAutocomplete(): this is AutocompleteInteraction<Context> & { type: ApplicationCommandAutocomplete }

Defined in: interactions/BaseInteraction.ts:490

Type guard: whether this is an autocomplete request for a slash command option.

this is AutocompleteInteraction<Context> & { type: ApplicationCommandAutocomplete }

BaseInteraction.isAutocomplete


isButton(): this is ButtonInteraction<Context>

Defined in: interactions/BaseInteraction.ts:460

Type guard: whether this is a button click interaction.

this is ButtonInteraction<Context>

BaseInteraction.isButton


isChannelSelect(): this is ChannelSelectInteraction<Context>

Defined in: interactions/BaseInteraction.ts:485

Type guard: whether this is a channel select menu interaction.

this is ChannelSelectInteraction<Context>

BaseInteraction.isChannelSelect


isChatInputCommand(): this is ChatInputCommandInteraction<Context>

Defined in: interactions/BaseInteraction.ts:421

Type guard: whether this is a chat input (slash) command interaction.

this is ChatInputCommandInteraction<Context>

BaseInteraction.isChatInputCommand


isCommand(): this is CommandInteraction<ApplicationCommandType, Context>

Defined in: interactions/BaseInteraction.ts:416

Type guard: whether this is an application command interaction (slash command or context menu command).

this is CommandInteraction<ApplicationCommandType, Context>

BaseInteraction.isCommand


protected isJSONEncodable(obj): obj is JSONEncodable<unknown>

Defined in: interactions/BaseInteraction.ts:188

unknown

obj is JSONEncodable<unknown>

BaseInteraction.isJSONEncodable


isMentionableSelect(): this is MentionableSelectInteraction<Context>

Defined in: interactions/BaseInteraction.ts:480

Type guard: whether this is a mentionable (user + role) select menu interaction.

this is MentionableSelectInteraction<Context>

BaseInteraction.isMentionableSelect


isMessageComponent(): this is MessageComponentInteraction<Context, MessageComponentType>

Defined in: interactions/BaseInteraction.ts:455

Type guard: whether this is a message component interaction (button or select menu).

this is MessageComponentInteraction<Context, MessageComponentType>

BaseInteraction.isMessageComponent


isMessageContextCommand(): this is MessageContextInteraction<Context>

Defined in: interactions/BaseInteraction.ts:437

Type guard: whether this is a message context menu command interaction.

this is MessageContextInteraction<Context>

BaseInteraction.isMessageContextCommand


isMessageModal(): this is ModalInteraction<Context & { message: APIMessage }>

Defined in: interactions/BaseInteraction.ts:450

Type guard: whether this is a modal submit interaction that opened from a message (not a slash command).

this is ModalInteraction<Context & { message: APIMessage }>

BaseInteraction.isMessageModal


isModal(): this is ModalInteraction<BaseInteractionContext>

Defined in: interactions/BaseInteraction.ts:445

Type guard: whether this is a modal submit interaction.

this is ModalInteraction<BaseInteractionContext>

BaseInteraction.isModal


isRoleSelect(): this is RoleSelectInteraction<Context>

Defined in: interactions/BaseInteraction.ts:475

Type guard: whether this is a role select menu interaction.

this is RoleSelectInteraction<Context>

BaseInteraction.isRoleSelect


isStringSelect(): this is StringSelectInteraction<Context>

Defined in: interactions/BaseInteraction.ts:465

Type guard: whether this is a string select menu interaction.

this is StringSelectInteraction<Context>

BaseInteraction.isStringSelect


isUserContextCommand(): this is UserContextInteraction<Context>

Defined in: interactions/BaseInteraction.ts:429

Type guard: whether this is a user context menu command interaction.

this is UserContextInteraction<Context>

BaseInteraction.isUserContextCommand


isUserSelect(): this is UserSelectInteraction<Context>

Defined in: interactions/BaseInteraction.ts:470

Type guard: whether this is a user select menu interaction.

this is UserSelectInteraction<Context>

BaseInteraction.isUserSelect


reply(options, forceEphemeral?): Promise<RESTPostAPIInteractionCallbackWithResponseResult>

Defined in: interactions/BaseInteraction.ts:273

Sends the initial response to the interaction.

string | InteractionResponseCallbackData

The message content, or a string shorthand for { content: options }

boolean = true

Whether to force the response to be ephemeral (visible only to the invoking user). Defaults to true.

Promise<RESTPostAPIInteractionCallbackWithResponseResult>

The created interaction response, including the created message.

BaseInteraction.reply


respond(choices): Promise<void>

Defined in: interactions/AutocompleteInteraction.ts:42

Sends autocomplete choices back to Discord.

APIApplicationCommandOptionChoice<string | number>[]

Up to 25 choices to display to the user.

Promise<void>


protected toSnakeCase<T>(obj): T

Defined in: interactions/BaseInteraction.ts:192

T = unknown

unknown

T

BaseInteraction.toSnakeCase


update(options): Promise<RESTPostAPIInteractionCallbackWithResponseResult>

Defined in: interactions/BaseInteraction.ts:374

Updates the original interaction response.

string | InteractionResponseCallbackData

The options to update the message with

Promise<RESTPostAPIInteractionCallbackWithResponseResult>

The updated message

This is mainly used for component interactions where you want to update the message the component is attached to OR for moodal submit interactions to update the message that opened the modal.

After calling this method, the interaction is considered replied and you need to use editReply to edit the original response.

BaseInteraction.update


userHavePremium(): boolean

Defined in: interactions/BaseInteraction.ts:222

Whether the user who triggered this interaction currently has an active, non-expired entitlement.

boolean

BaseInteraction.userHavePremium