Skip to main content
An Interaction is what you answer with: the interaction of a command is a CommandInteraction, the one of a button or a menu a ComponentInteraction, the one of a form a ModalInteraction. Discord wants a first answer within 3 seconds, and accepts edits and other messages for 15 minutes.
You never create an interaction: your run function receives one. This page lists everything it has; how to answer well (when to defer, ephemeral answers, what happens when run throws) is in Answering.

Properties

Snowflake
The unique id Discord gave it.
Date
When it was created: a Discord id contains its creation date.
User
Who did it.
Snowflake | null
The id of the server; null in a private message.
Snowflake
The id of the channel it happened in.
Guild | null
The server it happened in; null in a private message.
TextBasedChannel
The channel it happened in: Discord sends it with the interaction.
GuildMember | null
Who did it, as a member of the server; null in a private message.
Locale
The language of the person: use it to answer in their language.
boolean
Whether an answer was sent, or promised with defer().
boolean
Whether defer() was called and the answer is still to come. Also true after deferUpdate(), until update() or reply() completes it.

CommandInteraction

Someone used a slash command. It has everything above, plus:
string
The command as the person typed it: /mod ban.
And one more action, showModal().

ComponentInteraction

Someone clicked a button or picked something in a select menu of a message of the bot. It can answer like a command, or change the message the component is on. It has everything of Interaction, plus:
Message
The message the component is on.
And three more actions: update(), deferUpdate() and showModal(). Discord documentation

ModalInteraction

Someone sent a form of the bot. It can answer like a command; when a button or a menu opened the form, it can also change their message. It has everything of Interaction, plus:
Message | null
The message whose button or menu opened the form; null when a command did.
And two more actions: update() and deferUpdate(), which throw when message is null: “This form was opened by a command, not by a button or a menu: there is no message to change. Use interaction.reply().” Discord documentation

In a server, in private

What a command receives is more precise than CommandInteraction, and follows the where of the command. The same holds for components, with the InGuild, InPrivate and InDm types. With where: 'both', run receives GuildCommandInteraction | PrivateCommandInteraction: one if (interaction.guild) narrows everything. Discord documentation

Helpers

toJSON()

The data of the interaction, without its token: a token is a secret. console.log(interaction) never shows it either.

Actions

Answers are sent one after the other, in the order they were asked: you can call reply() and followUp() without waiting for the first to finish.

reply()

Answers. If defer() was called (by you, or by the framework because the answer was taking long), this completes the pending answer. Throws when the interaction was already answered: “This interaction was already answered. Use interaction.followUp() to send another message, or interaction.edit() to change the answer.” Discord documentation

defer()

Tells Discord the answer is coming: the person sees “thinking…” and reply() can then take up to 15 minutes. The framework does it by itself when an answer takes long; call it yourself to choose when. Does nothing when the interaction was already answered or deferred. Whether the answer is ephemeral is decided here: without ephemeral, it is what the command says.

update()

On a ComponentInteraction and a ModalInteraction. Changes the message the component is on, as the answer: its text, its embeds, its components, its files. Only what you pass changes; components: [] removes the buttons and menus. Throws when the interaction was already answered with a message or deferred with defer(): “This interaction was already answered: the message can no longer be changed through it. Use interaction.message.edit() to change the message, or interaction.followUp() to send another one.” Discord documentation

deferUpdate()

On a ComponentInteraction and a ModalInteraction. Tells Discord the message will change later: the person sees nothing meanwhile, and update() can then take up to 15 minutes. The framework does it by itself when an answer to a component takes long. After deferUpdate(), reply() sends its message as a follow-up, which looks the same to the person, and edit() changes the message of the component.

showModal()

On a CommandInteraction and a ComponentInteraction. Opens a form, as the answer: showModal(report({ userId })), with a form declared with modal(). It must be the first answer, and the person has as long as they want to fill it in. Throws when something was already answered: “A form can only be the first answer to an interaction: call interaction.showModal() before reply() or defer(), and the framework waits for it.” Discord documentation

edit()

Changes the answer. It takes a text, or MessageEditOptions. Throws when there is no answer yet: “There is no answer to edit yet: call interaction.reply() first.” Discord documentation

followUp()

Sends another message, after the answer. Throws when there is no answer yet: “A follow-up comes after an answer: call interaction.reply() first.” Discord documentation

delete()

Deletes the answer. Discord documentation

Types

InteractionReply

An answer to an interaction: its text, or its options. What reply() and followUp() take.

InteractionReplyOptions

The options of an answer: everything a message takes, except replyTo and stickers, plus ephemeral. It is listed in InteractionReplyOptions.