Interaction

Create a formatted Interaction Object

Constructor

new Interaction()

Example
const Interaction = new Interaction(request, client, response);

Members

appPermissions :number

bitwise set of permissions the app or bot has within the channel the interaction was sent from

Type:
  • number

applicationId :string

ID of the application this interaction is for

Type:
  • string

channelId :number

channel that the interaction was sent from

Type:
  • number

client :Application

the client that is bound to the interaction

commandName :string|null

interaction command name

Type:
  • string | null

components :Interaction

Return the components data of the interaction (for modals)

Example
const fieldTest = interaction.components.getDataById("fieldTest"); // Returns the object of field "fieldTest"!
const fieldTestValue = interaction.components.getDataById("fieldTest").value; // Returns the value of field "fieldTest"!
const fieldTestValueTwo = interaction.components.getValueById("fieldTest"); // Returns also the value of field "fieldTest"!

customId :string|null

interaction custom id

Type:
  • string | null

data :object

interaction data payload

Type:
  • object

entitlements :array

For monetized apps, any entitlements for the invoking user, representing access to premium SKUs

Type:
  • array

guild :object

the guild data of the interaction

Type:
  • object

id :string

ID of the interaction

Type:
  • string

locale :number

selected language of the invoking user

Type:
  • number

member :Member

the member data of the interaction

Type:

message :Message

the message data of the interaction

Type:

options :InteractionOptions

Return the options of the interaction

Example
const subCommandOption = interaction.options.getSubCommand(); // returns the subcommand option
const subCommandGroupOption = interaction.options.getSubCommandGroup(); // returns the subcommand group option
const stringOption = interaction.options.getString("optionName"); // returns the string option
const integerOption = interaction.options.getInteger("optionName"); // returns the integer option
const booleanOption = interaction.options.getBoolean("optionName"); // returns the boolean option
const userOption = interaction.options.getUser("optionName"); // returns the user option
const memberOption = interaction.options.getMember("optionName"); // returns the member option
const channelOption = interaction.options.getChannel("optionName"); // returns the channel option
const roleOption = interaction.options.getRole("optionName"); // returns the role option
const numberOption = interaction.options.getNumber("optionName"); // returns the number option
const mentionableOption = interaction.options.getMentionable("optionName"); // returns the mentionable option

token :string

continuation token for responding to the interaction

Type:
  • string

type :number

type of interaction

Type:
  • number

user :User

the user data of the interaction

Type:

values :array

select menu values if select menu interaction

Type:
  • array

Methods

deferReply(ephemeral)

ACK an interaction and edit a response later, the user sees a loading state

Parameters:
NameTypeDefaultDescription
ephemeralbooleanfalse

if the message should be ephemeral

Example
interaction.deferReply(true); // true or false to make it ephemeral

deferUpdate()

For components, ACK an interaction and edit the original message later; the user does not see a loading state

Example
interaction.deferUpdate();

editReply(options)

Edit the Reply

Parameters:
NameTypeDescription
options

The message payload (embeds, components, content, files, ephemeral)

Properties
NameTypeDescription
contentstring

The content of the message

embedsarray

The embeds of the message

componentsarray

The components of the message

filesarray

The files of the message

Example
const response = await interaction.editReply({ content: "Hello World" });
console.log(response);

followUp(options)

Send a simple follow-up message

Parameters:
NameTypeDescription
options

The message payload (embeds, components, content, files, ephemeral)

Properties
NameTypeDescription
contentstring

The content of the message

embedsarray

The embeds of the message

componentsarray

The components of the message

filesarray

The files of the message

ephemeralboolean

If the message should be ephemeral

Example
const response = await interaction.followUp({ content: "Hello World" });
console.log(response);

getEntitlements() → {array}

Get all entitlements for the current application

Returns:
Type: 
array

guildHavePremium() → {boolean}

Check if the guild has a premium subscription

Returns:
Type: 
boolean

isAutoComplete() → {boolean}

Check if the interaction is an auto complete

Returns:
Type: 
boolean

isCommand() → {boolean}

Check if the interaction is an application command

Returns:
Type: 
boolean

isComponent() → {boolean}

Check if the interaction is a message component

Returns:
Type: 
boolean

isInGuild() → {boolean}

Check if the interaction is in a guild

Returns:
Type: 
boolean

isModal() → {boolean}

Check if the interaction is a modal submit

Returns:
Type: 
boolean

reply(options)

Reply to an Interaction

Parameters:
NameTypeDescription
options

The message payload (embeds, components, content, files, ephemeral)

Properties
NameTypeDescription
contentstring

The content of the message

embedsarray

The embeds of the message

componentsarray

The components of the message

filesarray

The files of the message

ephemeralboolean

If the message should be ephemeral

Example
interaction.reply({ content: "Hello World" });

replyPremium()

Reply to an Interaction with a premium message

Example
interaction.replyPremium();

sendAutoComplete(choices)

Response to an autocomplete interaction

Parameters:
NameTypeDescription
choicesArray.<object>

the choices including (name, name_localizations?, value)

showModal(modal)

Response to an interaction with a modal

Parameters:
NameTypeDescription
modalobject | modal
Example
const { Modal, TextInput, TextInputStyles } = require('interactions.js');

 const modal = new Modal()
     .setCustomId("test")
     .setTitle("Test Modal")
     .addComponent(
         new ActionRow()
             .addComponent(
                 new TextInput()
                     .setCustomId("test")
                     .setPlaceholder("test")
                     .setStyle(TextInputStyles.Short)
                     .setLabel("test")
             )
     );

return interaction.showModal(modal);

update(options)

Update an Interaction

Parameters:
NameTypeDescription
options

The message payload (embeds, components, content, files)

Example
interaction.update({ content: "Hello World" });

userHavePremium() → {boolean}

Check if the user has a premium subscription

Returns:
Type: 
boolean