Skip to content

MessageComponentInteraction ​

classe · Source

Represents a message component interaction.

Extends: InteractionImplements: InteractionResponses

Properties ​

channelId ​

channelId: Snowflake

The id of the channel this interaction was sent in Source

message ​

message: Message | APIMessage

The message to which the component was attached Source

customId ​

customId: string

The custom id of the component which was interacted with Source

componentType ​

componentType: string

The type of component which was interacted with Source

deferred ​

deferred: boolean

Whether the reply to this interaction has been deferred Source

ephemeral ​

nullable

ephemeral: boolean

Whether the reply to this interaction is ephemeral Source

replied ​

replied: boolean

Whether this interaction has already been replied to Source

webhook ​

webhook: InteractionWebhook

An associated interaction webhook, can be used to further interact with this interaction Source

component ​

readonly

component: MessageActionRowComponent | APIMessageActionRowComponent

The component which was interacted with Source

type ​

type: InteractionType

The interaction's type Source

id ​

id: Snowflake

The interaction's id Source

token ​

readonly

token: string

The interaction's token Source

applicationId ​

applicationId: Snowflake

The application's id Source

guildId ​

nullable

guildId: Snowflake

The id of the guild this interaction was sent in Source

user ​

user: User

The user which sent this interaction Source

member ​

nullable

member: GuildMember | APIGuildMember

If this interaction was sent in a guild, the member which sent it Source

version ​

version: number

The version Source

appPermissions ​

nullable

appPermissions: Readonly<Permissions>

Set of permissions the application or bot has within the channel the interaction was sent from Source

memberPermissions ​

nullable

memberPermissions: Readonly<Permissions>

The permissions of the member, if one exists, in the channel this interaction was executed in Source

locale ​

locale: Locale

The locale of the user who invoked this interaction Source

guildLocale ​

nullable

guildLocale: Locale

The preferred locale from the guild this interaction was sent in Source

authorizingIntegrationOwners ​

authorizingIntegrationOwners: AuthorizingIntegrationOwners

Owners for each installation context that authorized this interaction. Source

createdTimestamp ​

readonly

createdTimestamp: number

The timestamp the interaction was created at Source

createdAt ​

readonly

createdAt: Date

The time the interaction was created at Source

channel ​

readonly · nullable

channel: TextBasedChannels

The channel this interaction was sent in Source

guild ​

readonly · nullable

guild: Guild

The guild this interaction was sent in Source

client ​

readonly

client: Client

The client that instantiated this Source

Methods ​

deferReply ​

async

async deferReply(options?: InteractionDeferReplyOptions): Promise<(Message|APIMessage|void)>

Defers the reply to this interaction. Parameters

NameTypeDescription
options?InteractionDeferReplyOptionsOptions for deferring the reply to this interaction

Returns: Promise<(Message\|APIMessage\|void)>

js
// Defer the reply to this interaction
interaction.deferReply()
  .then(console.log)
  .catch(console.error)
js
// Defer to send an ephemeral reply later
interaction.deferReply({ ephemeral: true })
  .then(console.log)
  .catch(console.error);

Source

reply ​

async

async reply(options: string | MessagePayload | InteractionReplyOptions): Promise<(Message|APIMessage|void)>

Creates a reply to this interaction. Use the fetchReply option to get the bot's reply message. Parameters

NameTypeDescription
optionsstring | MessagePayload | InteractionReplyOptionsThe options for the reply

Returns: Promise<(Message\|APIMessage\|void)>

js
// Reply to the interaction and fetch the response
interaction.reply({ content: 'Pong!', fetchReply: true })
  .then((message) => console.log(`Reply sent with content ${message.content}`))
  .catch(console.error);
js
// Create an ephemeral reply with an embed
const embed = new MessageEmbed().setDescription('Pong!');

interaction.reply({ embeds: [embed], ephemeral: true })
  .then(() => console.log('Reply sent.'))
  .catch(console.error);

Source

fetchReply ​

fetchReply(message?: MessageResolvable | '@original'): Promise<(Message|APIMessage)>

Fetches a reply to this interaction. Parameters

NameTypeDescription
message?MessageResolvable | '@original'The response to fetch Default: '@original'.

Returns: Promise<(Message\|APIMessage)>

js
// Fetch the initial reply to this interaction
interaction.fetchReply()
  .then(reply => console.log(`Replied with ${reply.content}`))
  .catch(console.error);

Source

editReply ​

async

async editReply(options: string | MessagePayload | InteractionEditReplyOptions): Promise<(Message|APIMessage)>

Edits a reply to this interaction. Parameters

NameTypeDescription
optionsstring | MessagePayload | InteractionEditReplyOptionsThe new options for the message

Returns: Promise<(Message\|APIMessage)>

js
// Edit the initial reply to this interaction
interaction.editReply('New content')
  .then(console.log)
  .catch(console.error);

Source

deleteReply ​

async

async deleteReply(message?: MessageResolvable | '@original'): Promise<void>

Deletes a reply to this interaction. Parameters

NameTypeDescription
message?MessageResolvable | '@original'The response to delete Default: '@original'.

Returns: Promise<void>

js
// Delete the initial reply to this interaction
interaction.deleteReply()
  .then(console.log)
  .catch(console.error);

Source

followUp ​

async

async followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<(Message|APIMessage)>

Send a follow-up message to this interaction. Parameters

NameTypeDescription
optionsstring | MessagePayload | InteractionReplyOptionsThe options for the reply

Returns: Promise<(Message\|APIMessage)>Source

deferUpdate ​

async

async deferUpdate(options?: InteractionDeferUpdateOptions): Promise<(Message|APIMessage|void)>

Defers an update to the message to which the component was attached. Parameters

NameTypeDescription
options?InteractionDeferUpdateOptionsOptions for deferring the update to this interaction

Returns: Promise<(Message\|APIMessage\|void)>

js
// Defer updating and reset the component's loading state
interaction.deferUpdate()
  .then(console.log)
  .catch(console.error);

Source

update ​

async

async update(options?: string | MessagePayload | InteractionUpdateOptions): Promise<(Message|APIMessage|void)>

Updates the original message of the component on which the interaction was received on. Parameters

NameTypeDescription
options?string | MessagePayload | InteractionUpdateOptionsThe options for the updated message

Returns: Promise<(Message\|APIMessage\|void)>

js
// Remove the components from the message
interaction.update({
  content: "A component interaction was received",
  components: []
})
  .then(console.log)
  .catch(console.error);

Source

showModal ​

async

async showModal(modal: Modal | ModalOptions): Promise<void>

Shows a modal component Parameters

NameTypeDescription
modalModal | ModalOptionsThe modal to show

Returns: Promise<void>Source

awaitModalSubmit ​

awaitModalSubmit(options: AwaitModalSubmitOptions): Promise<ModalSubmitInteraction>

Collects a single modal submit interaction that passes the filter. The Promise will reject if the time expires. Parameters

NameTypeDescription
optionsAwaitModalSubmitOptionsOptions to pass to the internal collector

Returns: Promise<ModalSubmitInteraction>

js
// Collect a modal submit interaction
const filter = (interaction) => interaction.customId === 'modal';
interaction.awaitModalSubmit({ filter, time: 15_000 })
  .then(interaction => console.log(`${interaction.customId} was submitted!`))
  .catch(console.error);

Source

inGuild ​

inGuild(): boolean

Indicates whether this interaction is received from a guild. Returns: booleanSource

inCachedGuild ​

inCachedGuild(): boolean

Indicates whether or not this interaction is both cached and received from a guild. Returns: booleanSource

inRawGuild ​

inRawGuild(): boolean

Indicates whether or not this interaction is received from an uncached guild. Returns: booleanSource

isApplicationCommand ​

isApplicationCommand(): boolean

Indicates whether this interaction is a BaseCommandInteraction. Returns: booleanSource

isCommand ​

isCommand(): boolean

Indicates whether this interaction is a CommandInteraction. Returns: booleanSource

isContextMenu ​

isContextMenu(): boolean

Indicates whether this interaction is a ContextMenuInteractionReturns: booleanSource

isModalSubmit ​

isModalSubmit(): boolean

Indicates whether this interaction is a ModalSubmitInteractionReturns: booleanSource

isUserContextMenu ​

isUserContextMenu(): boolean

Indicates whether this interaction is a UserContextMenuInteractionReturns: booleanSource

isMessageContextMenu ​

isMessageContextMenu(): boolean

Indicates whether this interaction is a MessageContextMenuInteractionReturns: booleanSource

isAutocomplete ​

isAutocomplete(): boolean

Indicates whether this interaction is an AutocompleteInteractionReturns: booleanSource

isMessageComponent ​

isMessageComponent(): boolean

Indicates whether this interaction is a MessageComponentInteraction. Returns: booleanSource

isButton ​

isButton(): boolean

Indicates whether this interaction is a ButtonInteraction. Returns: booleanSource

isSelectMenu ​

isSelectMenu(): boolean

Indicates whether this interaction is a SelectMenuInteraction. Returns: booleanSource

isRepliable ​

isRepliable(): boolean

Indicates whether this interaction can be replied to. Returns: booleanSource

resolveType ​

static · private

resolveType(type: MessageComponentTypeResolvable): MessageComponentType

Resolves the type of a MessageComponent Parameters

NameTypeDescription
typeMessageComponentTypeResolvableThe type to resolve

Returns: MessageComponentTypeSource

Unofficial software. Not affiliated with or supported by Discord.