InteractionResponses
interface · Source
Interface for classes that support shared interaction response types.
Methods
deferReply
Defers the reply to this interaction. Parameters
| Name | Type | Description |
|---|---|---|
options? | InteractionDeferReplyOptions | Options for deferring the reply to this interaction |
Returns: Promise<(Message\|APIMessage\|void)>
// Defer the reply to this interaction
interaction.deferReply()
.then(console.log)
.catch(console.error)// Defer to send an ephemeral reply later
interaction.deferReply({ ephemeral: true })
.then(console.log)
.catch(console.error);reply
Creates a reply to this interaction. Use the fetchReply option to get the bot's reply message. Parameters
| Name | Type | Description |
|---|---|---|
options | string | MessagePayload | InteractionReplyOptions | The options for the reply |
Returns: Promise<(Message\|APIMessage\|void)>
// 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);// 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);fetchReply
Fetches a reply to this interaction. Parameters
| Name | Type | Description |
|---|---|---|
message? | MessageResolvable | '@original' | The response to fetch Default: '@original'. |
Returns: Promise<(Message\|APIMessage)>
// Fetch the initial reply to this interaction
interaction.fetchReply()
.then(reply => console.log(`Replied with ${reply.content}`))
.catch(console.error);editReply
Edits a reply to this interaction. Parameters
| Name | Type | Description |
|---|---|---|
options | string | MessagePayload | InteractionEditReplyOptions | The new options for the message |
Returns: Promise<(Message\|APIMessage)>
// Edit the initial reply to this interaction
interaction.editReply('New content')
.then(console.log)
.catch(console.error);deleteReply
Deletes a reply to this interaction. Parameters
| Name | Type | Description |
|---|---|---|
message? | MessageResolvable | '@original' | The response to delete Default: '@original'. |
Returns: Promise<void>
// Delete the initial reply to this interaction
interaction.deleteReply()
.then(console.log)
.catch(console.error);followUp
Send a follow-up message to this interaction. Parameters
| Name | Type | Description |
|---|---|---|
options | string | MessagePayload | InteractionReplyOptions | The options for the reply |
Returns: Promise<(Message\|APIMessage)>Source
deferUpdate
Defers an update to the message to which the component was attached. Parameters
| Name | Type | Description |
|---|---|---|
options? | InteractionDeferUpdateOptions | Options for deferring the update to this interaction |
Returns: Promise<(Message\|APIMessage\|void)>
// Defer updating and reset the component's loading state
interaction.deferUpdate()
.then(console.log)
.catch(console.error);update
Updates the original message of the component on which the interaction was received on. Parameters
| Name | Type | Description |
|---|---|---|
options? | string | MessagePayload | InteractionUpdateOptions | The options for the updated message |
Returns: Promise<(Message\|APIMessage\|void)>
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);showModal
Shows a modal component Parameters
| Name | Type | Description |
|---|---|---|
modal | Modal | ModalOptions | The modal to show |
Returns: Promise<void>Source
awaitModalSubmit
Collects a single modal submit interaction that passes the filter. The Promise will reject if the time expires. Parameters
| Name | Type | Description |
|---|---|---|
options | AwaitModalSubmitOptions | Options to pass to the internal collector |
Returns: Promise<ModalSubmitInteraction>
// 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);