discord.slash_class v1.0.69
slash command
A nice custom class to handle slash commands This does not support creating slash commands - you have to do that yourself
Usage
const { Client } = require("discord.js");
const SlashCommand = require("discord.slash_class");
const client = new Client()
client.on("raw", (p) => {
if (p.t != "INTERACTION_CREATE") return; //if it's not the slash command event
if (p.d.type != 2) return; //if it's not a slash command
let command = new SlashCommand(p.d, client)
switch (command.name) {
case "ping": { /* /ping just got executed by someone - guild or global command, it doesn't care */
command.reply("Pong!")
}
case "help": { /* Someone did /help */
command.reply("insert help here")
}
}
})
Documentation of the custom class
command.client - The bot client
command.commandID - The slash command ID
command.guild - The guild object of the guild the slash command was executed in
command.member - The member object of the person who executed the slash command
command.channel - can't guess what that one is based on the two last ones :Kappa:
command.data - Ok, so that one is a little bit more complex. This abrits the arguments of your slash command. I can not offer support for this one. Please use console.log to see it's content depending on the arguments passed and see how to handle them yourself.
command.think() - This will make your bot go [Bot name] is thinking...
. If you run this, you are not able to send ephemeral messages after this. THIS HAS TO BE AWAITED (await command.think())
command.reply(message content, list of embeds, boolean for ephemeral) - All three arguments of this function are optional.