1.1.2 • Published 4 years ago

discord-command-handler v1.1.2

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Just for me

i created this package just for me if someone wants to use this feel free ;)

Features

  • The Command Class load all javascript files in a given path and make them available as discord commands
  • Build in Settings with <Commando>.get(guild, key) and <Commando>.set(guild, key, value)

Use the Client

require('dotenv').config();
const path = require('path');
const Commando = require('discord-command');

const client = new Commando({
    Prefix: '!',
    Owner: [ "your discord id here" ],
    SQLitePath: path.join(__dirname, 'settings.sqlite3'), // if not set the Class will create one
});

client.loadCommands(path.join(__dirname, 'commands')); // you need to create sub directories which match with command group property
client.login(process.env.token); // discord bot token here

Example command Class

class Ping {
    constructor() {
        this.name = "ping"; // this needs to be the name of your js file: ping.js
        this.group = "util"; // this must match the sub directory within your commands path lile commands/util/ping.js
        this.alias = [ "p", "pong" ] // you can use as many alias as you want
        this.guildOnly = false; // speeks for itself
        this.adminOnly = true; // Server Admins only
        this.ownerOnly = true; // Bot Owner only
    }
    // client = Commando Class (extends Discord)
    // msg = the incoming Message (with a few extras, like cleanMessage the message text without the prefix)
    async run(client, msg, args, alias) {
        return msg.reply(`${alias === "pong" ? "Ping" : "Pong"}!`);
    }
}
module.exports = Ping;

Latest Version

  • Minor bug fixes (a guild only command in DM caused an error)
  • The Handler checks now for adminOnly and ownerOnly when the Command Class has this propertys