Skip to content

CommandInteraction

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

Application command interaction with fully typed option resolver.

new CommandInteraction(client, data): CommandInteraction

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

InteractionClient

InteractionData

CommandInteraction

Interaction.constructor

readonly applicationId: string

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

Application identifier.

Interaction.applicationId


readonly optional channelId?: string

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

Channel identifier.

Interaction.channelId


readonly data: InteractionData

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

Raw interaction data.

Interaction.data


deferred: boolean = false

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

Whether the initial response was deferred.

Interaction.deferred


readonly optional guildId?: string

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

Guild identifier.

Interaction.guildId


readonly id: string

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

Interaction identifier.

Interaction.id


readonly options: CommandOptions

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

Typed option resolver. Access slash command options with full type safety.


replied: boolean = false

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

Whether the initial response was sent.

Interaction.replied


readonly token: string

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

Interaction token.

Interaction.token


readonly type: number

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

Interaction type.

Interaction.type

get commandName(): string

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

Invoked command name.

string

Command name or an empty string.


get createdTimestamp(): number

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

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

number

Interaction.createdTimestamp


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[]

Interaction.entitlements


get expiresAt(): Date

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

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

Date

Interaction.expiresAt


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

Interaction.isExpired


get member(): GuildMember | null

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

The invoking guild member, or null outside a guild.

GuildMember | null

Interaction.member


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

Interaction.user

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" });

Interaction.awaitModalSubmit


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.

Interaction.deferReply

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.

Interaction.deferReply


deleteFollowUp(messageId): Promise<void>

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

Deletes a follow-up message.

string

Follow-up message ID.

Promise<void>

Interaction.deleteFollowUp


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.

Interaction.deleteReply


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>

Interaction.editFollowUp


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.

Interaction.editReply


fetchReply(): Promise<unknown>

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

Fetches the original response message.

Promise<unknown>

Interaction.fetchReply


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.

Interaction.followUp


hasEntitlement(skuId): boolean

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

Whether the interaction carries an active entitlement for a SKU.

string

boolean

Interaction.hasEntitlement


isAnySelectMenu(): this is ComponentInteraction

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

Whether this is any select menu interaction.

this is ComponentInteraction

Interaction.isAnySelectMenu


isAutocomplete(): this is AutocompleteInteraction

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

Whether this interaction is autocomplete.

this is AutocompleteInteraction

True for autocomplete interactions.

Interaction.isAutocomplete


isButton(): this is ComponentInteraction

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

Whether this is a button interaction.

this is ComponentInteraction

Interaction.isButton


isChannelSelectMenu(): this is ComponentInteraction

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

Whether this is a channel select menu interaction.

this is ComponentInteraction

Interaction.isChannelSelectMenu


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

Interaction.isChatInputCommand


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

Interaction.isCommand


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

Interaction.isContextMenuCommand


isMentionableSelectMenu(): this is ComponentInteraction

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

Whether this is a mentionable select menu interaction.

this is ComponentInteraction

Interaction.isMentionableSelectMenu


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.

Interaction.isMessageComponent


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

Interaction.isMessageContextMenuCommand


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.

Interaction.isModalSubmit


isRoleSelectMenu(): this is ComponentInteraction

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

Whether this is a role select menu interaction.

this is ComponentInteraction

Interaction.isRoleSelectMenu


isStringSelectMenu(): this is ComponentInteraction

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

Whether this is a string select menu interaction.

this is ComponentInteraction

Interaction.isStringSelectMenu


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

Interaction.isUserContextMenuCommand


isUserSelectMenu(): this is ComponentInteraction

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

Whether this is a user select menu interaction.

this is ComponentInteraction

Interaction.isUserSelectMenu


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.

Interaction.reply

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.

Interaction.reply


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.

Interaction.showModal


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>

Interaction.update

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>

Interaction.update