discwork

1.0.3 • Public • Published

discwork npm JavaScript Style Guide

💿 A Discord.js command framework. 🛠

Setup

The following will install discwork and Discord.js:

npm i -s discwork discord.js

For additional packages of Discord.js, see the Discord.js Installation page.

Usage

const Discord = require('discord.js')
const client = new Discord.Client()

var discwork = require('discwork')(client)

client.on('ready', () => {
  console.log(`MyBot logged in as ${client.user.tag}!`);
})

discwork.add(/^mb!ping$/, (message, matches) => { // Simple command
  message.reply(`${client.ping}ms`)
})

discwork.add(/^mb!echo (.+)$/, (message, matches) => { // Command with parameters
  message.reply(matches[1]) // Get first parameter (0th element of array is the full command text)
})

discwork.done()

client.login('token')

Documentation

.add

Adds a command.

Parameters

  • regex - The command RegExp, or an array of RegExpes
  • action - The command handler function

Example

discwork.add(/^mb!ping$/, (message, matches) => {
  message.reply(`${client.ping}ms`)
})

.done

Finishes the command list. Must be called after all commands were added.

Example

discwork.done()

Readme

Keywords

Package Sidebar

Install

npm i discwork

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

4.24 kB

Total Files

4

Last publish

Collaborators

  • skiilaa