@tomdev/discord.js-command-handler
v1.4.0
Published
Command handler for discord.js bots
Downloads
13
Readme
Discord.js Command Handler
Easily manage commands.
Install
npm i @tomdev/discord.js-command-handler
Usage
Main file
//discord.js libary
var discord = require("discord.js")
var client = new discord.Client({intents: [discord.Intents.FLAGS.GUILDS, discord.Intents.FLAGS.GUILD_MESSAGES]})
var handler = require("@tomdev/discord.js-command-handler")
//initialize handler, pass client, folder with command files, prefix
var prefix = "!" //same for every server
/*var prefix = { //define for each server
"default": "!" //if server hasn't
"6166856194426361379": "?" //prefix for server with id
"6166856194426361380": "$" //prefix for server with id
}*/
var cmdhandler = new handler(client, "/commands", prefix)
//handle command on message event
client.on("messageCreated", (message) => {
cmdhandler.handleCommand(message)
})
Command files
Example commands on Github
module.exports = {
name: "example", //neded
aliases: ["e", "exa"],
category: "Main",
description: "This is an example command",
usage: "!example",
run: async function (client, command, args, message) { //needed
message.channel.send("Hello World!")
}
}
Features and Description
Find all methods and properties on Wiki