Setting up Slash Commands
Usage
const { SlashCommandBuilder } = require("discord.js");
// I recommend you define the command name and description here to prevent
// retyping them if you decide to have prefix and slash command to call the cmd
const name = "ping";
const description = "Ping Pong Command";
module.exports = {
name,
description,
aliases: ['p'],
guildOnly: true,
permissions: 0,
minArgs: 0,
usage: '',
// defines as slash command using Discord.js SlashCommandBuilder
data: new SlashCommandBuilder()
.setName(name)
.setDescription(description),
execute(message, args, client) {
return message.channel.send({
content: 'Pong'
});
},
async interactionReply(interaction) { // define what the slash command does
await interaction.reply({
content: 'Pong!'
});
}
};Properties
Property
Type
Required
Description
Last updated