Skip to content

Interaction

Defined in: packages/structures/src/interactions.ts:167

Base interaction structure.

TData extends InteractionData = InteractionData

new Interaction<TData>(client, data): Interaction<TData>

Defined in: packages/structures/src/interactions.ts:192

Creates an interaction from a Gateway payload.

InteractionClient

Interaction transport.

TData

Gateway interaction payload.

Interaction<TData>

If required identifiers are missing.

readonly applicationId: string

Defined in: packages/structures/src/interactions.ts:171

Application identifier.


readonly optional channelId?: string

Defined in: packages/structures/src/interactions.ts:177

Channel identifier.


readonly data: TData

Defined in: packages/structures/src/interactions.ts:181

Raw interaction data.


deferred: boolean = false

Defined in: packages/structures/src/interactions.ts:185

Whether the initial response was deferred.


readonly optional guildId?: string

Defined in: packages/structures/src/interactions.ts:175

Guild identifier.


readonly id: string

Defined in: packages/structures/src/interactions.ts:169

Interaction identifier.


replied: boolean = false

Defined in: packages/structures/src/interactions.ts:183

Whether the initial response was sent.


readonly token: string

Defined in: packages/structures/src/interactions.ts:173

Interaction token.


readonly type: number

Defined in: packages/structures/src/interactions.ts:179

Interaction type.

get createdTimestamp(): number

Defined in: packages/structures/src/interactions.ts:396

Unix timestamp (ms) at which the interaction was created, from its snowflake.

number


get entitlements(): readonly APIEntitlement[]

Defined in: packages/structures/src/interactions.ts:205

The entitlements of the person (and guild) that ran this interaction: what they own from your SKUs.

readonly APIEntitlement[]


get expiresAt(): Date

Defined in: packages/structures/src/interactions.ts:400

When the interaction token stops working (15 minutes after creation).

Date


get isExpired(): boolean

Defined in: packages/structures/src/interactions.ts:404

Whether the token has expired; no response, edit or follow-up can succeed after that.

boolean


get member(): GuildMember | null

Defined in: packages/structures/src/interactions.ts:381

The invoking guild member, or null outside a guild.

GuildMember | null


get user(): User | null

Defined in: packages/structures/src/interactions.ts:372

The invoking user (from member.user in guilds, user in DMs).

User | null

awaitModalSubmit(options): Promise<ModalSubmitInteraction>

Defined in: packages/structures/src/interactions.ts:262

Waits for this user to submit a modal, typically one this interaction just opened with showModal.

time (required, ms); optional customId and filter.

string

(interaction) => boolean | Promise<boolean>

number

Promise<ModalSubmitInteraction>

The submission.

When time runs out first or no client is attached.

const submitted = await interaction.awaitModalSubmit({ time: 60_000, customId: "feedback" });

deferReply(options): Promise<Message | null>

Defined in: packages/structures/src/interactions.ts:513

Defers the initial interaction response. true or { ephemeral: true } makes the eventual response private; withResponse: true returns the placeholder message.

boolean

true

Promise<Message | null>

When already acknowledged or REST fails.

deferReply(options?): Promise<void>

Defined in: packages/structures/src/interactions.ts:517

Defers the initial interaction response. true or { ephemeral: true } makes the eventual response private; withResponse: true returns the placeholder message.

boolean | { ephemeral?: boolean; withResponse?: boolean; }

Promise<void>

When already acknowledged or REST fails.


deleteFollowUp(messageId): Promise<void>

Defined in: packages/structures/src/interactions.ts:439

Deletes a follow-up message.

string

Follow-up message ID.

Promise<void>


deleteReply(): Promise<void>

Defined in: packages/structures/src/interactions.ts:545

Deletes the original response.

Promise<void>

Promise fulfilled after deletion.

When not acknowledged or REST fails.


editFollowUp(messageId, options): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:432

Edits a follow-up message.

string

Follow-up message ID.

string | InteractionReplyOptions

Promise<unknown>


editReply(options): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:536

Edits the original response.

InteractionReplyOptions

Replacement message options.

Promise<unknown>

Discord response.

When not acknowledged or REST fails.


fetchReply(): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:427

Fetches the original response message.

Promise<unknown>


followUp(options): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:553

Sends a follow-up message using the interaction webhook.

string | InteractionReplyOptions

Follow-up message options.

Promise<unknown>

Discord response.

When not acknowledged (Discord has no webhook before the initial response) or REST fails.


hasEntitlement(skuId): boolean

Defined in: packages/structures/src/interactions.ts:212

Whether the interaction carries an active entitlement for a SKU.

string

boolean


isAnySelectMenu(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:334

Whether this is any select menu interaction.

this is ComponentInteraction


isAutocomplete(): this is AutocompleteInteraction

Defined in: packages/structures/src/interactions.ts:300

Whether this interaction is autocomplete.

this is AutocompleteInteraction

True for autocomplete interactions.


isButton(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:310

Whether this is a button interaction.

this is ComponentInteraction


isChannelSelectMenu(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:330

Whether this is a channel select menu interaction.

this is ComponentInteraction


isChatInputCommand(): this is CommandInteraction

Defined in: packages/structures/src/interactions.ts:235

Whether this interaction is a slash (chat input) command. Since 0.2.2 this is false for context-menu commands; use isCommand for both.

this is CommandInteraction


isCommand(): this is CommandInteraction

Defined in: packages/structures/src/interactions.ts:228

Whether this interaction is any application command: slash or context menu.

this is CommandInteraction


isContextMenuCommand(): this is ContextMenuCommandInteraction

Defined in: packages/structures/src/interactions.ts:239

Whether this interaction is a user or message context-menu command.

this is ContextMenuCommandInteraction


isMentionableSelectMenu(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:326

Whether this is a mentionable select menu interaction.

this is ComponentInteraction


isMessageComponent(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:292

Whether this interaction is a message component.

this is ComponentInteraction

True for component interactions.


isMessageContextMenuCommand(): this is ContextMenuCommandInteraction

Defined in: packages/structures/src/interactions.ts:248

Whether this interaction is a message context-menu command (right-click a message).

this is ContextMenuCommandInteraction


isModalSubmit(): this is ModalSubmitInteraction

Defined in: packages/structures/src/interactions.ts:296

Whether this interaction is a modal submission.

this is ModalSubmitInteraction

True for modal submissions.


isRoleSelectMenu(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:322

Whether this is a role select menu interaction.

this is ComponentInteraction


isStringSelectMenu(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:314

Whether this is a string select menu interaction.

this is ComponentInteraction


isUserContextMenuCommand(): this is ContextMenuCommandInteraction

Defined in: packages/structures/src/interactions.ts:244

Whether this interaction is a user context-menu command (right-click a user).

this is ContextMenuCommandInteraction


isUserSelectMenu(): this is ComponentInteraction

Defined in: packages/structures/src/interactions.ts:318

Whether this is a user select menu interaction.

this is ComponentInteraction


reply(options): Promise<Message | null>

Defined in: packages/structures/src/interactions.ts:492

Sends the initial interaction response. With withResponse: true it returns the created Message in the same request (no fetchReply()).

InteractionReplyOptions & object

Promise<Message | null>

When already acknowledged or REST fails.

reply(options): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:495

Sends the initial interaction response. With withResponse: true it returns the created Message in the same request (no fetchReply()).

string | InteractionReplyOptions

Promise<unknown>

When already acknowledged or REST fails.


showModal(modal): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:599

Opens a modal dialog in the user’s client.

{ toJSON: { components: unknown[]; custom_id: string; title: string; }; } | { components: readonly unknown[]; custom_id: string; title: string; }

Modal builder output or raw modal callback data.

Promise<unknown>

Discord response.

When already acknowledged or REST fails.


update(options): Promise<Message | null>

Defined in: packages/structures/src/interactions.ts:567

Updates the message a component is on. With withResponse: true it returns the updated Message.

InteractionReplyOptions & object

Promise<Message | null>

update(options): Promise<unknown>

Defined in: packages/structures/src/interactions.ts:570

Updates the message a component is on. With withResponse: true it returns the updated Message.

string | InteractionReplyOptions

Promise<unknown>