Skip to content

InteractionResponses

interface · Source

Interface for classes that support shared interaction response types.

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

Unofficial software. Not affiliated with or supported by Discord.