Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

A custom Eris command handler designed for Forbidden Statistics

License

Notifications You must be signed in to change notification settings

harrisonhoward/eris.js-commando

Repository files navigation

Read Github README, in case of unpublished changes

Eris.js-Commando

not a clone of discord.js-commando
A custom Eris command handler designed for Forbidden Statistics

npm install eris.js-commando

Install forbidden-node-logger for a colour node console logger

npm install forbidden-node-logger

NPM Version NPM Downloads

Features

Commands, Groups and Parent Groups

Give your bot project structure with Parent Groups and Groups. With these structures you can make having hundreds of commands a breeze to navigate through.
Example:

    - Basic
        * ping.js
        * help.js
        * invite.js
    - Config
        - Join and Leave
            * join.js
            * leave.js
        - Logging
            * mod-log.js
            * action-log.js

Database Providers

In-built SQLiteProvider and MongoDBProvider to allow you quickly and efficiently start using a database without the hassle of having to build functions yourself.
MongoDB

const MongoDBProvider = Commando.MongoDBProvider;
const { MongoClient } = require("mongodb");
bot.setProvider(
    new MongoDBProvider({ host: settings.host, name: settings.name, auth: settings.auth }),
    MongoClient
);

SQLite

const SQLite = require("sqlite");
const SQLiteProvider = Commando.SQLiteProvider;
const Path = require("path");
bot.setProvider(
    SQLite.open(Path.join(__dirname + "settings.sqlite")).then(db => new sqlite(db))
);

Custom Logging with File Support

Support for forbidden-node-logger allows you to save logs file and keep your previous 1000 logs in cache without having to manually open your bot terminal.
npm install forbidden-node-logger

bot.Logger.log("Super cool log command!");
bot.Logger.history.first();
bot.Logger.fileHistory.getLatestLog();

Utility Manager

In-built utility manager allows you to use useful functions. The default functions include getting a users tag (username + discriminator) and others allows you to add, get different settings from storage using a map over having to manage your database yourself.
Along with these features you can add your own utils onto the manager itself.
to keep typings you would have to modify the typings file, I'm looking into better options

bot.util.useful.getUserTag(message.author);
function loadUtils(bot) {
    if (!bot.util.checkProps("myfunctions")) {
        bot.util.myfunctions = myfunctions;
    }
    bot.util.bindAll();
}

Webhook Manager

In-built webhook manager allows you to quickly have your bot listen on a port and wait on a sub-directory url (i.e. "/request").
This is useful for bots waiting for votes from popular listing sites like Bots for Discord and Discord Bot List.

bot.webhookmngr.listenOn(5000);
bot.webhookmngr.waitFor(5000, "/bfdwebhook", (bot data) => {}, "MyBFDAuth");
bot.webhookmngr.waitFor(5000, "/dblwebhook", (bot, data) => {}, "MyDBLAuth");

Getting Started

Basic Bot

const Commando = require("eris.js-commando");
const bot = Commando.CommandClient(token, {}, {
    name: "CoolErisBot",
    description: "My super cool bot that can do everything!",
    prefix: "!"
}, { dirPath: __dirname + "/logs" }); 
// replace { dirPath: __dirname + "/logs" } with false if you don't have "forbidden-node-logger"
// Along with that remove all bot.Logger references

bot.Logger.on("error", () => {});
bot.on("ready", () => {
    bot.Logger.log("none", `Client ready! Logged in as &-6${bot.user.username}&r (&-c${bot.user.id}&r)`);
});

bot.registerGroup("Basic", "basic");
bot.registerCommandsIn(__dirname + "/commands");

bot.connect();

Test Scripts

In the project directory you can run the following scripts (Make sure you have the environment setup correctly):

npm run base

Will run the Base Test of the handler
Located at test/BaseTest/bot.js

npm run full

Will run the Full Test of the handler
Located at test/FullTest/bot.js