Skip to content

MessageContextMenuInteraction

classe · Source

Represents a message context menu interaction.

Extends: ContextMenuInteraction

Properties

targetMessage

readonly

targetMessage: Message | APIMessage

The message this interaction was sent from Source

options

options: CommandInteractionOptionResolver

The target of the interaction, parsed into options Source

targetId

targetId: Snowflake

The id of the target of this interaction Source

targetType

targetType: ApplicationCommandType

The type of the target of the interaction; either USER or MESSAGE Source

channelId

channelId: Snowflake

The id of the channel this interaction was sent in Source

commandId

commandId: Snowflake

The invoked application command's id Source

commandName

commandName: string

The invoked application command's name Source

deferred

deferred: boolean

Whether the reply to this interaction has been deferred Source

replied

replied: boolean

Whether this interaction has already been replied to Source

ephemeral

nullable

ephemeral: boolean

Whether the reply to this interaction is ephemeral Source

webhook

webhook: InteractionWebhook

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

command

nullable

command: ApplicationCommand

The invoked application command, if it was fetched before 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

resolveContextMenuOptions

private

resolveContextMenuOptions(data: APIApplicationCommandInteractionData): Array<CommandInteractionOption>

Resolves and transforms options received from the API for a context menu interaction. Parameters

NameTypeDescription
dataAPIApplicationCommandInteractionDataThe interaction data

Returns: Array<CommandInteractionOption>Source

transformResolved

private

transformResolved(resolved: APIInteractionDataResolved): CommandInteractionResolvedData

Transforms the resolved received from the API. Parameters

NameTypeDescription
resolvedAPIInteractionDataResolvedThe received resolved objects

Returns: CommandInteractionResolvedDataSource

transformOption

private

transformOption(option: APIApplicationCommandOption, resolved: APIInteractionDataResolved): CommandInteractionOption

Transforms an option received from the API. Parameters

NameTypeDescription
optionAPIApplicationCommandOptionThe received option
resolvedAPIInteractionDataResolvedThe resolved interaction data

Returns: CommandInteractionOptionSource

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

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

Unofficial software. Not affiliated with or supported by Discord.