Command Framework
A framework to easily do commands using discord.js
Installation
Check that you have node and npm installed
- To check if you have Node.js installed, run this command in your terminal:
node -v
- To confirm that you have npm installed you can run this command in your terminal:
npm -v
- Ok, now an installation of our npm
npm i command-discord
Usage
const command = ;// all parameters in this object are optional, you can pass token in the start function, bellow parameters are the defaultconst client = command; clientstart; // to start the bot you can pass token here, if you dont pass options
- All parameters (client options) can be used in external codes -- Example: client.prefix, client.color, client.external.Discord
- For restart your bot use in your code
client;
Console Error
client
Bot Playing
client;
Commands Examples
- Let's do a simple avatar command
// commands/others/avatar.js// we can do this command in this way exportsname = "avatar"exportshelp = "See someone avatar"exportscooldown = 2 // cooldown in secondsexportscdMessage = "Wait 2 seconds to use this again" // message if someone try to use command in cooldownexportsaliases = "profilepic""picture" exportscategory = "others" // optional better for filters// all params are opcionalexports{ // params.message is the message for the command you can use params.message.client for the client //param.prefix for the prefix and param.args for command argumentes const messageargs = params; messagechannel} // or we can do this more "beutifull"moduleexports = new { thisname = "avatar"; thiscategory = "others" thishelp = "See someone avatar"; thiscooldown = 2; thiscdMessage = "Wait 2 seconds to use this again"; thisaliases = "profilepic""picture" } { // buildMessage is used for embeds // you can pass an channel id to send}
- Help Command
// commands/help.js// commands/help/help.jsmoduleexports = new { thisname = "help"; thiscategory = "others" thishelp = "See my commands"; thiscooldown = 2; thiscdMessage = "Wait 2 seconds to use this again"; thisaliases = "cmds""commands" } { // or we can just send a category commands }
- Ping Command
// commands/others/ping.jsmoduleexports = new { thisname = "ping"; thiscategory = "others"; thishelp = "I show my latency"; thiscooldown = 3; thiscdMessage = "Wait 3 seconds to use this again"; thisaliases = "pong" } { message }
You can find the documentation of discord.js Here
Example of bot using this framework Here