cmder.js
A node.js module to handle Discord.js commands and events.
Installation
Run one of the following commands based on your package manager:
npm install cmder.js
pnpm add cmder.js
yarn add cmder.js
Quickstart
Install the package, then create a new file in your root directory called 'cmder.yaml'.
This will be our configuration file. It will look something like this:
paths:
events: ./src/events
commands: ./src/commands
Now, our src/index.js file:
const { Client } = require("discord.js");
const { Handler } = require("cmder.js");
const client = new Client({
});
new Handler(client);
client.login(TOKEN);
File setup
project
├── cmder.yaml
├── package.json
└── src/
├── index.js
├── commands/
│ ├── General/
│ │ ├── ping.js
│ └── Misc/
│ ├── info.js
├── events/
│ ├── Client/
│ │ ├── ready.js
│ └── Messages/
│ ├── messageCreate.js
Events
- The name of the folder (e.g. "Client") does not matter.
- The name of the file (e.g. "ready.js" or "console-log.js") does not matter.
What matters is what the event exports, which should look like this:
src/events/Client/ready.js
module.exports = {
name: "ready"
once: true,
run: (c) => {
console.log(`${c.user.tag} is now online!`);
}
};
Commands
Commands are similar to events—neither the folder name nor the file name matter, but the exports do:
src/commands/General/ping.js
module.exports = {
data: {
name: "ping",
description: "Replies with Pong!",
},
run: ({ interaction, client, handler }) => {
interaction.reply("Pong!!!");
},
};