1.0.0 • Published 4 years ago

coolcaedframework v1.0.0

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

A discord.js framework, making it easy to create commands and events, saving you the time of having to make a handler. You can view the example code here

Yes the code of this is very messy it was kinda rushed

Creating the client

NameTypeRequiredDescription
prefixStringtrueThe prefix used at the start of commands
tokenStringtrueThe bots/users token of the account used to authenticate
ownerIdStringfalseThe ID of the bots owner (not required if a selfbot)
selfbotBooleanfalseIs the bot a selfbot or normal bot
eventsPathStringtrueThe directory path for the event files
inhibitorsPathStringtrueThe directory path for the inhibitor files
commandsPathStringtrueThe directory path for the command files
const { Client } = require('coolcaedFramework');
const path = require('path');

const client = new Client({
    token: 'super-secret-token-here', // Token of the bot
    prefix: "!", // Prefix for bot commands
    selfbot: false, // Is the bot a selfbot or not
    ownerId: '199248578122612736', // Owner's id of the bot (can be empty if a selfbot)

    commandsPath: path.join(__dirname, 'commands'), // Path of the commands directory
    eventsPath: path.join(__dirname, 'events'), // Path of the events directory
    inhibitorsPath: path.join(__dirname, 'inhibitors') // Path of the events directory
});

client.login();

Creating an command

These commands will be executed by the prefix set on Client.prefix followed by the command name or one of the aliases

NameTypeRequiredDescription
nameStringtrueName of the command
descriptionStringfalseDescription of the command (what it does etc)
aliasesArrayfalseCommand aliases (other triggers of the command)
guildOnlyBoleanfalseShould the command only be allowed in guilds only?
categoryStringfalseThe category the command is in
cooldownIntegerfalseTime a user should wait before doing the command again (in seconds)
inhibitorsArrayfalseInhibitors that should be ran before calling the commands run function
const { Command } = require('coolcaedFramework');

module.exports = class extends Command {
    constructor(...args) {
        super(...args, {
            enabled: true,
            name: 'ping',
            description: 'Ping pong',
            category: 'General',
            guildOnly: true,
            cooldown: 3,
            aliases: ['pong'],
            inhibitors: ["isDev"]
        });
    }

    run(msg, args) {
        msg.channel.send('Pong');
    }
}

Creating an event

The code will be triggered when ever an event is emitted by discord.js

NameTypeRequiredDescription
eventStringtrueName of the event
onceBooleanfalseShould the event be ran once
const { Event } = require('coolcaedFramework');

module.exports = class extends Event {
    constructor(...args) {
        super(...args, {
            event: 'ready',
            once: true
        });
    }

    run() {
        console.log(`Logged in as ${this.client.user.tag}`);
    }
}

Creating an inhibitor

These are ran before the commands run function gets called, the name of the inhibitor should be passed into the Command.inhibitors array

nameTypeRequiredDescription
nameStringtrueName of the inhibitor
const { Inhibitor } = require('coolcaedFramework');

module.exports = class extends Inhibitor {
    constructor(...args) {
        super(...args, {
            enabled: true,
            name: 'isDev'
        });
    }

    run(msg, cmd) {
        if (!msg.author.id === this.client.ownerId) throw "You're not a developer";
    }
}

If you find any bugs or errors in this code, please contact me on discord: Caed#0024