Constructor
new Interaction()
- Source
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
- number
applicationId :string
ID of the application this interaction is for
- string
channelId :number
channel that the interaction was sent from
- number
client :Application
the client that is bound to the interaction
- Source
commandName :string|null
interaction command name
- string |
null
- Source
components :Interaction
Return the components data of the interaction (for modals)
- Source
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
- string |
null
data :object
interaction data payload
- object
- Source
entitlements :array
For monetized apps, any entitlements for the invoking user, representing access to premium SKUs
- array
- Source
guild :object
the guild data of the interaction
- object
id :string
ID of the interaction
- string
locale :number
selected language of the invoking user
- number
member :Member
the member data of the interaction
message :Message
the message data of the interaction
options :InteractionOptions
Return the options of the interaction
- Source
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
- string
type :number
type of interaction
- number
user :User
the user data of the interaction
values :array
select menu values if select menu interaction
- array
- Source
Methods
deferReply(ephemeral)
ACK an interaction and edit a response later, the user sees a loading state
Name | Type | Default | Description |
---|---|---|---|
ephemeral | boolean | false | if the message should be ephemeral |
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
interaction.deferUpdate();
editReply(options)
Edit the Reply
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | The message payload (embeds, components, content, files, ephemeral) Properties
|
const response = await interaction.editReply({ content: "Hello World" });
console.log(response);
followUp(options)
Send a simple follow-up message
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | The message payload (embeds, components, content, files, ephemeral) Properties
|
const response = await interaction.followUp({ content: "Hello World" });
console.log(response);
getEntitlements() → {array}
Get all entitlements for the current application
- Type:
- array
guildHavePremium() → {boolean}
Check if the guild has a premium subscription
- Type:
- boolean
isAutoComplete() → {boolean}
Check if the interaction is an auto complete
- Type:
- boolean
isCommand() → {boolean}
Check if the interaction is an application command
- Type:
- boolean
isComponent() → {boolean}
Check if the interaction is a message component
- Type:
- boolean
isInGuild() → {boolean}
Check if the interaction is in a guild
- Type:
- boolean
isModal() → {boolean}
Check if the interaction is a modal submit
- Type:
- boolean
reply(options)
Reply to an Interaction
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | The message payload (embeds, components, content, files, ephemeral) Properties
|
interaction.reply({ content: "Hello World" });
replyPremium()
Reply to an Interaction with a premium message
interaction.replyPremium();
sendAutoComplete(choices)
Response to an autocomplete interaction
Name | Type | Description |
---|---|---|
choices | Array.<object> | the choices including (name, name_localizations?, value) |
showModal(modal)
Response to an interaction with a modal
Name | Type | Description |
---|---|---|
modal | object | |
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
Name | Type | Description |
---|---|---|
options | The message payload (embeds, components, content, files) |
interaction.update({ content: "Hello World" });
userHavePremium() → {boolean}
Check if the user has a premium subscription
- Type:
- boolean