A NodeJS bot micro-framework for Discord.
This repository has been archived on 2022-03-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Find a file
2019-07-26 21:33:28 +02:00
lib Simplified key/value args parsing + added support for spaces inside quotes 2019-07-26 21:33:28 +02:00
.gitignore Initial commit (untested) 2019-04-29 15:16:09 +02:00
index.js Exit on Ctrl-C 2019-07-20 11:23:13 +02:00
LICENSE Initial commit 2019-04-28 17:30:38 +02:00
package.json Added UI.table 2019-07-20 23:48:00 +02:00
README.md Typo 2019-06-18 03:28:11 +02:00
yarn.lock Added UI.table 2019-07-20 23:48:00 +02:00

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