Socket
Socket
Sign inDemoInstall

discwork

Package Overview
Dependencies
92
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    discwork

A discord.js command framework.


Version published
Maintainers
1
Install size
1.30 MB
Created

Readme

Source

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()

Keywords

FAQs

Last updated on 17 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc