Skip to content

BaseInteraction

Abstract Class: BaseInteraction<Type, Context>

Section titled “Abstract Class: BaseInteraction<Type, Context>”

Defined in: interactions/BaseInteraction.ts:83

Base class for all typed Discord interactions. Wraps the raw interaction payload with response helpers (reply, editReply, followUp, …), type guards (isButton, isModal, …), and convenience getters mirroring the raw payload’s fields.

Not instantiated directly — use one of the concrete subclasses (ChatInputCommandInteraction, ButtonInteraction, ModalInteraction, etc.), which Honocord constructs and passes to handlers.

Type extends InteractionType

Context extends BaseInteractionContext = BaseInteractionContext

new BaseInteraction<Type, Context>(api, data, context): BaseInteraction<Type, Context>

Defined in: interactions/BaseInteraction.ts:101

API

Extract<APIApplicationCommandAutocompleteInteraction, { type: Type; }> | Extract<APIChatInputApplicationCommandInteraction, { type: Type; }> | Extract<APIMessageApplicationCommandInteraction, { type: Type; }> | Extract<APIUserApplicationCommandInteraction, { type: Type; }> | Extract<APIPrimaryEntryPointCommandInteraction, { type: Type; }> | Extract<APIMessageComponentInteraction, { type: Type; }> | Extract<APIModalSubmitInteraction, { type: Type; }>

Context

BaseInteraction<Type, Context>

protected _ephemeral: boolean | null = null

Defined in: interactions/BaseInteraction.ts:93


protected api: API

Defined in: interactions/BaseInteraction.ts:102


readonly context: Context

Defined in: interactions/BaseInteraction.ts:97

The Hono interaction context this interaction was created from.


protected deferred: boolean = false

Defined in: interactions/BaseInteraction.ts:95


readonly fetcher: Fetcher

Defined in: interactions/BaseInteraction.ts:99

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


protected readonly raw: Extract<APIApplicationCommandAutocompleteInteraction, { type: Type; }> | Extract<APIChatInputApplicationCommandInteraction, { type: Type; }> | Extract<APIMessageApplicationCommandInteraction, { type: Type; }> | Extract<APIUserApplicationCommandInteraction, { type: Type; }> | Extract<APIPrimaryEntryPointCommandInteraction, { type: Type; }> | Extract<APIMessageComponentInteraction, { type: Type; }> | Extract<APIModalSubmitInteraction, { type: Type; }>

Defined in: interactions/BaseInteraction.ts:90

The raw interaction data


protected replied: boolean = false

Defined in: interactions/BaseInteraction.ts:94


readonly rest: REST

Defined in: interactions/BaseInteraction.ts:92

REST client used to make requests to the Discord API.


readonly type: Type

Defined in: interactions/BaseInteraction.ts:88

The interaction’s Discord interaction type.

get applicationId(): string

Defined in: interactions/BaseInteraction.ts:114

The ID of the application this interaction was sent to.

string


get appPermissions(): string

Defined in: interactions/BaseInteraction.ts:179

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

string


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


get channelId(): string | undefined

Defined in: interactions/BaseInteraction.ts:124

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

string | undefined


get entitlements(): APIEntitlement[]

Defined in: interactions/BaseInteraction.ts:119

Entitlements for the invoking user, for monetized apps.

APIEntitlement[]


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


get guildId(): string | undefined

Defined in: interactions/BaseInteraction.ts:134

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

string | undefined


get guildLocale(): Locale | undefined

Defined in: interactions/BaseInteraction.ts:164

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

Locale | undefined


get id(): string

Defined in: interactions/BaseInteraction.ts:174

The interaction’s ID.

string


get locale(): Locale | undefined

Defined in: interactions/BaseInteraction.ts:159

The invoking user’s locale.

Locale | undefined


get member(): APIInteractionGuildMember | undefined

Defined in: interactions/BaseInteraction.ts:154

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

APIInteractionGuildMember | undefined


get token(): string

Defined in: interactions/BaseInteraction.ts:169

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

string


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


get userId(): string | undefined

Defined in: interactions/BaseInteraction.ts:144

The ID of the user who triggered the interaction.

string | undefined


get version(): 1

Defined in: interactions/BaseInteraction.ts:184

Discord’s interaction payload version (always 1).

1

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>


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.

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.


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.


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.


getAppEntitlements(): APIEntitlement[]

Defined in: interactions/BaseInteraction.ts:207

Returns entitlements belonging to this interaction’s application.

APIEntitlement[]


guildHavePremium(): boolean

Defined in: interactions/BaseInteraction.ts:212

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

boolean


inDM(): this is BaseInteraction<Type, 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<Type, BaseInteractionContext> & { guild: undefined; guild_id: undefined; guild_locale: undefined }


inGuild(): this is BaseInteraction<Type, 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<Type, BaseInteractionContext> & { guild: APIPartialInteractionGuild; guild_id: string; guild_locale: Locale }


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 }


isButton(): this is ButtonInteraction<Context>

Defined in: interactions/BaseInteraction.ts:460

Type guard: whether this is a button click interaction.

this is ButtonInteraction<Context>


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>


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>


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>


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

Defined in: interactions/BaseInteraction.ts:188

unknown

obj is JSONEncodable<unknown>


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>


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>


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>


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 }>


isModal(): this is ModalInteraction<BaseInteractionContext>

Defined in: interactions/BaseInteraction.ts:445

Type guard: whether this is a modal submit interaction.

this is ModalInteraction<BaseInteractionContext>


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>


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>


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>


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>


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.


protected toSnakeCase<T>(obj): T

Defined in: interactions/BaseInteraction.ts:192

T = unknown

unknown

T


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.


userHavePremium(): boolean

Defined in: interactions/BaseInteraction.ts:222

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

boolean