README
What is it?
SmolHandler is a Disocord.js Command and Event handler, that can read through all the files in a directory, and yes it can also go in directories inside the commands/events directory, which is very helpfull in organizing your commands!
Download
NPM
npm i smolhandler
Yarn
yarn add smolhandler
Setting Up
First, we need to include the module into the project.
const { Command, Event } = require("smol-handler");
Now we can setup the Command and Event handler. Check out the "Examples" sections for you know exaples.
Examples
Following example assume that your Discord client is client
.
Command Handler
- Main File
client.on("message", (message) => {
Command(client, message, {
// the directory for your command files
directory: path.join(__dirname, "./commands"),
// examples bellow are the object value names, and you can change however you like
// for example you can change aliases to be aliases: "al"
aliases: "aliases", // optional
cooldown: "cooldown" // optional
});
});
- Commands File
module.exports = {
name: "command name",
aliases: ["command", "aliases"], // optional
cooldown: "5s", // optional
run: (client, messsage, args) => {
// command output
}
};
Event Handler
- Main File
client.on("message", (message) => {
Event(client, {
// the directory for your event files
directory: path.join(__dirname, "./events")
});
});
- Events File
module.exports = {
name: "message",
run: (client, message) => {
// event output
}
};