What is a Command
A Command is an order that executes your code upon certain text triggers. They are executed by a user typing your bot prefix followed by a specific word/phrase that executes the code you have written to go with that word or phrase. Commands are the heart of every bot giving you the opportunity to use your creativity in making the best possible Commands that perform extraordinary tasks.
Commands can be restricted to certain permission levels as well as whether they can be carried out in DMs. You also have the opportunity to add aliases to your Commands, therefore giving users a variety of words or phrases to pick from to execute your code from an individual Command file. In addition, you can choose to disable a Command easily.
Spark already contains some pre-made Commands for you:
-
about
Shows information about the bot & framework.
-
ping
Test the latency between Discord's servers and the bot.
-
reload
Allows the owner to reload modules without restarting.
-
reboot
Allows the owner to restart the bot.
-
help
Shows the command list and detailed command information.
Below you will find out how to create a Command, as well as the methods and properties that may be used to help you with creating a Command.
Constructor
To create a Command, you will need to create a new ".js" file inside the commands folder.
Below is an example of how a default Command file is structured:
var Spark = require("sparkbots") const Command = Spark.command("name-cmd") Command.addAlias("alias-1") Command.setLevel(0) Command.allowDms(false) Command.code = (client, message) => { // Execute Code Here } module.exports = Command;
Methods
-
addAlias( Name )
-
Name
-
-
setLevel( Number )
-
Number
-
-
allowDms( Boolean )
-
Boolean
-
-
addHelpField( Title, Value, Inline )
-
Title
-
Value
-
Inline
-
-
.disable()
Properties
-
level
-
name