-
Notifications
You must be signed in to change notification settings - Fork 1
5) Adding Slash Commands
First create a file that ends with .js
extension and another same-named file that ends with .struct.js
located in
the directory you specified in the config.json
's slashCommands.directory
property.
Enter the file that ends with .struct.js
and make a Slash Command.
Example:
new SlashCommandBuilder()
.setDescription("example, " + guild.name)
.setName("example");
You can click me and see the docs of Discord.SlashCommandBuilder
Now you can just add your in-file config and start coding!
This should be defined in your in-file config.
This will be used while handling the command.
Example situation: If your command's structure name is myCommand
and someone uses /myCommand
command in a channel
that your bot can see this command file will be triggered.
This is an optional property and false
by default.
If you want your command to get triggered by using it adds this property.
This is an optional property and false
by default.
If you want your command to be able to run in DMs add this property.
This is an optional property and false
by default.
If you want your command to be able to run by bots add this property.
Check Prefixed-slash commands page for prefixed-slash in-file configurations.
This stops your command and can have limitless arguments which won't matter.
This is a Discord.Interaction
instance which caused your command.
This is a Discord.Channel
instance where the message was sent.
This is a Discord.Guild
instance or undefined
if you enabled dmAllowed
and used the command in a DM channel.
This is the language got from the guild of the interaction. Example: en_US
An object
which represent the arguments of the slash command. Example: args.myTextArgument
A string
or undefined
which is the used sub command used by the user.
A string
or undefined
which is the used sub command group used by the user.
Discord.SlashCommandBuilder
that you built in the .struct.js
file.
This is a NodeJS.Global.SlashCommand
instance which represents the current command. You can get in-file config
properties using it: command.getConfigValue("name")