A simple to use command handler for discord.js v12
npm install @lumap/commandhandlerindex.js
``javascript
const Discord = require('discord.js')
const client = new Discord.Client()
let commandHandler = require('@lumap/commandhandler')
let cmdDir="./commands/", ownerID="635383782576357407", helpCommand=true
let handler = new commandHandler(client,cmdDir,ownerID,{helpCommand})
let respondsToBots=false, mentionAsPrefix=true, mentionToKnowPrefix=true
client.on('message', async (msg) => {
handler.message(msg,prefix="?",{respondsToBots,mentionAsPrefix,mentionToKnowPrefix})
})
client.login("YOUR_TOKEN")
`
./commands/ping.js
`javascript``
module.exports = {
name: "ping",
aliases: ['p'],
description: "Shows bot ping",
usage: "ping",
ownerOnly: false,
run: async (msg,args,client) => {
msg.channel.send('Pong! '+client.ws.ping+'ms!')
}
}
N.B.: Everything between the { } are optional arguments,you're not forced to provide them. In the examples above,the default values are used. If you don't provide a prefix, it will be set to "!"