Skip to content

4) Adding Prefixed Commands

Oğuzhan edited this page Jul 21, 2022 · 5 revisions

First create a file that ends with .js extension located in the directory you specified in the config.json's prefixCommands.directory property.

Now you can just add your in-file config and start coding!

In-file config properties

name

This should be defined in your in-file config.

This will be used while handling the command.

Example situation: If your prefix is ! and your command's name is hello whenever someone types !hello to a text channel that your bot can see this command file will be triggered.

enabled

This is an optional property and false by default.

If you want your command to get triggered by using it adds this property.

dmAllowed

This is an optional property and false by default.

If you want your command to be run in DMs add this property.

botAllowed

This is an optional property and false by default.

If you want your command to be run by bots add this property.

External variables

stop()

This stops your command and can have limitless arguments which won't matter.

message

This is a Discord.Message instance which caused your command.

channel

This is a Discord.Channel instance where the message was sent.

guild

This is a Discord.Guild instance or undefined if you enabled dmAllowed and used the command in a DM channel.

prefix

This is the prefix. Example: !

language

This is the language got from the guild of the message. Example: en_US

args

An array of string which represent the arguments of the command.

command

This is a NodeJS.Global.PrefixCommand instance which represents the current command. You can get in-file config properties using it: command.getConfigValue("name")