A NodeJS bot micro-framework for Discord.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KaKi87 4cbc1f47c5 Simplified key/value args parsing + added support for spaces inside quotes 3 weeks ago
lib Simplified key/value args parsing + added support for spaces inside quotes 3 weeks ago
.gitignore Initial commit (untested) 3 months ago
LICENSE Initial commit 3 months ago
README.md Typo 2 months ago
index.js Exit on Ctrl-C 1 month ago
package.json Added UI.table 1 month ago
yarn.lock Added UI.table 1 month ago

README.md

discord-microframework

Interaction-oriented NodeJS bot micro-framework for Discord.

Getting started

Prerequisites

  • NodeJS
  • NPM
  • Yarn

Install

From npm

yarn add discord-microframework

or

npm i discord-microframework

Use

const Discord = require('discord-microframework');

Bot

Instanciation

const Bot = new Discord.Bot(name, token, logLevel);
  • name string
  • token string
  • logLevel string

Start / Stop

Bot.start();
Bot.stop();
Discord.Bot.startAll();
Discord.Bot.stopAll();

Command handler

Instanciation

const myCommandHandler = new Discord.CommandHandler(name, prefix, bots, channels, logLevel);
  • name string
  • prefix string
  • bots boolean - Decide wether to handle commands from bots or not.
    (default : false)
  • channels array - Channels ID where commands are handled.
    (default : null — means everywhere)
  • logLevel string

Commands subscription

myCommandHandler.subscribe(command => {
    // do something
});
  • cmd string - Command without prefix and parameters
  • args array - Command parameters
  • args_assoc object - Associative command parameters (parsed askey=value)
  • del function - Delete command
  • out function - Output response (short for ‘output’)
    • message string
  • rep function - Output response with mention (short for ‘reply’)
    • message string
  • dm function - Output response in DM
    • message string
  • react function
    • reaction(s) string or array - Unicode emoji characters

Handler activation

Bot.use(myCommandHandler);

Reaction handler

Instanciation

const myReactionHandler = new Discord.ReactionHandler(name, emojis);
  • name string
  • emojis array - Unicode emoji characters

Handler activation

Bot.use(myReactionHandler);

Handler listening

myReactionHandler.listen(message, callbacks, user, remove, bots, logLevel);

Getters

Bot.channels()
Bot.guilds()
Bot.users()

Classes

Discord.RichEmbed

Built with

Node modules :

Changelog

  • 1.0.0 (2019-06-??) • Initial release