discordjs-cmds

0.9.0 • Public • Published

~ discordjs-cmds ~

Simple-to-use command parser for discord.js

   

npm install discordjs-cmds --save

👉 JSDOCS


Contents


Disclaimer

This project is currently in an early development phase, which means, that there could be some unidentified bugs. Also, there will be much more functions added and advanced later! Feel free to post issues or pull request if you noticed a bug or if you have improvement suggestions!


Usage

Implement the library, create your bot framework and create an instance of the CmdParser

const { Client } = require('discord.js')
const { CmdParser } = require('discordjs-cmds')
 
// Creating bot instance
const bot = new Client()
// Creating CmdParser  Instance
const cmd = new CmdParser(bot, "-")
 
// Login the bot instance with your discord token
bot.login(/*bot token*/)

Now, create some methods for commands somewhere

function cmd_say(msg, args) {
    msg.channel.send(args.join(' '))
}
 
function cmd_ping(msg, args) {
    msg.channel.send('Pong!')
}
 
// ...

Then, you can register your commands like following

cmd.register(cmd_say, "say", ["tell", "send"], "Send a message with the bot", "-say <msg>", cmd.type.CHAT, 1)
   .register(cmd_ping, "ping")

For permissions, you can register specific permission levels for specific roles

cmd.setPerms(["2134792837489213749", "2319480812347123431"], 1)
   .setPerms("8757023480239487232", 2)

If you want to react on some events the CmdParser event manager fires, use it like following

cmd.on('commandFailed', (errtype) => console.log(`Failed Command: ${errtype}`))

Default Commands

There are some default implemented commands:

help

Sends the user a list of commands via DM

help <invoke>

Get the help message of a registered command


Changelog

All changelogs (after version 0.3.0) you can find in the CHANGELOG.md.


To-Do

  • Add option + function to give guilds higher perm lvl
  • Method to register bot host with max perm lvl
  • Guild specific prefixes
  • Custom command types
  • Aliases
  • Permissions
  • Detailed help command

Package Sidebar

Install

npm i discordjs-cmds

Weekly Downloads

2

Version

0.9.0

License

MIT

Unpacked Size

32.9 kB

Total Files

7

Last publish

Collaborators

  • zekro