Slash Commands
Discord.Short allows an easier method of creating slash commands!
When writing a slash command, its very similar to a normal command.
Lets start by creating a slash command, this is what one would normally look like:
new ds.Command({
name: 'help',
description: 'Need Help?', // required in a slash command
slash: true, // making this command into a slash command
guild: '839993561280938035', // optional
async execute({arguments}) {
// args
}
});where you see arguments, you can add any of these arguments:
interaction- the actual interaction coming from the commandchannel- the channel the command was used inguild- the server the command was used inauthor- the user who used the commandargs[]- the arguments after the commandsend()- sending a message in the channel where the command was executed
so lets add a reply, ill be requiring MessageEmbed from discord.js
Overall, the file will look something like this:
again, we can run the bot using node
now, you can see the command on the / list:

and when we run it, we get this:

Just like when you create normal commands, you can use arguments. But this is a bit different and required two more parameters:
Then, when we run this in discord, we will get this:


Last updated
Was this helpful?