EZCMDS
Easy command and event handler for discord.js without classes.
https://www.npmjs.com/package/easycommands
If you would like to use the version with classes visit:Set up - main file (not with event handler)
const Discord = ;const client = ; const Handler = ;const handler = ; handler; client; client;
Example Command inside ./commands/test.js
exportsrun = async { // code goes here. messagechannel; } exportshelp = name: "test" // required aliases: 'test1' 'test2' // optional. cooldown: 60000 // optional. in milliseconds
Example using event handler. Main file:
const Discord = ;const client = ; const Handler = ;const handler = ; handler; client;
Inside ./events/message.js
exportsrun = async { if!messageguild return; const prefix = "!"; if!messagecontent return; const messageArray = messagecontent; const cmd = messageArray0; const args = messageArray; clienthandler; }
The command example will remain the same as above.
Bonus: Using the handler and being able to pass additional variables.
Inside ./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 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 }
Then inside ./commands/test.js
exportsrun = async { messagechannel; // expected output: "extra variables now work" } exportshelp = name: "test"