2.0.2 • Published 4 years ago
discord-interactions-helper v2.0.2
discord-interactions-helper
First
The type of the variable "interactions" is InteractionHelper.
const Discord = require('discord.js');
const client = new Discord.Client();
const interactions = require('discord-interactions-helper')(client);
// Enter the code here
client.login(TOKEN);
Create a Guild Slash Command
interactions.on('ready', () => {
const manager = interactions.guildCommands.resolve(GUILD_ID);
manager.create(
"goodmorning", // arg1: name
"Good morning command", // arg2: description(optional)
{ } // arg3: options(optional)
);
});
Create a Global Slash Command
interactions.on('ready', () => {
interactions.globalCommands.create(
"goodmorning", // arg1: name
"Good morning command", // arg2: description(optional)
{ } // arg3: options(optional)
);
});
Get/Edit a Guild Slash Command
interactions.on('ready', () => {
const manager = interactions.guildCommands.resolve(GUILD_ID);
const command = manager.cache.get(COMMAND_ID);
command.edit({
description: "Good morning command"
});
});
Get/Edit a Global Slash Command
interactions.on('ready', () => {
const command = interactions.globalCommands.cache.get(COMMAND_ID);
command.edit({
description: "Good morning command"
});
});
Receive a Slash Commands and Respond to the Interaction
The type of the paramater "interaction" is discord-interactions-helper.SlashCommandInteraction.
interactions.on('receiveSlashCommand', (interaction, webhook) => {
console.log("Receive!");
interaction.reply({
content: "Recieved!"
});
webhook.send("Followup Message 1");
webhook.send("Followup Message 2");
});
Receive a Component Interaction and Respond to the Interaction
The type of the paramater "interaction" is discord-interactions-helper.ComponentInteraction.
interactions.on('receiveComponent', (interaction, webhook) => {
console.log("Receive!");
interaction.reply({
content: "Recieved!"
});
webhook.send("Followup Message 1");
webhook.send("Followup Message 2");
});