EASYCOMMANDS
Easy to use command handler with discord.js. Note this command handler is for beginners.
Set up - main file
const Discord = ;const client = ; const EasyCommands = ;const handler = ; handler; client; client;
Example command inside ./commands/help.js
const Command = ; { super name: "help" // required aliases: 'help1' 'help2' // optional usage: "help" // optional description: "Show all commands." // optional category: "General" // optional. Defaults to 'General' cooldown: 60000 // optional. Defaults to 0. Time is in milliseconds. ; } async { message; } moduleexports = Help;
Using Event Handler - main file
const Discord = ;const client = ; const EasyCommands = ;const handler = ; handler; client;
Using Event Handler - message event in ./events/message.js
exportsrun = async { if!messageguild return; // return if the message was sent in DMs const prefix = "!"; // define prefix if!messagecontent return; // if the message content doesn't start with our prefix return. const messageArray = messagecontent; // split the message content at every space const cmd = messageArray0; // get the command that was run const args = messageArray; // define your args clienthandler; // will run command if it is found. Will also catch errors. }
Using handler and being able to pass variables you want to the command.
In message event file with cooldowns:
exportsrun = async { if!messageguild return; // return if the message was sent in DMs const prefix = "!"; // define prefix if!messagecontent return; // if the message content doesn't start with our prefix return. const messageArray = messagecontent; // split the message content at every space const cmd = messageArray0; // get the command that was run const args = messageArray; // define your args const cool = clienthandler; // want to remove cooldowns? Remove this line and the following: ifcool return messagechannel; // remove this line too const command = clienthandler; if!command return; command; clienthandler; // remove this line too }
Inside ./commands/help.js for testing:
const Command = ; { super name: "help" // required aliases: 'help1' 'help2' // optional usage: "help" // optional description: "Show all commands." // optional category: "General" // optional. Defaults to 'General' cooldown: 5000 // optional. Defaults to 0. Time is in milliseconds. ; } async { message; // expected output: @author, extra, variables, now, work } moduleexports = Help;