A lightweight Discord.js framework for single-server bots (company discord bots, internal management, etc.).
No need to hand-write slash command registration or event routing, so you can focus on the core design of your bot.
It just works, and it's what we use across our own internal bots.
Note: This framework is designed towards single-server bots, however we are planning on changing this in the near future.
npm install github:kryptoninnovations/botframe#mainRequires discord.js ^14.26.4 in your project.
const { FrameworkClient } = require('botframe');
const client = new FrameworkClient({
commandsPath: __dirname + '/commands',
eventsPath: __dirname + '/events',
devUserIds: ['123456789012345678'],
});
client.start(process.env.TOKEN);These get passed into new FrameworkClient({ ... }):
commandsPath- folder containing your command category subfolderseventsPath- folder containing your event name subfoldersdevUserIds- user IDs allowed to rundevOnlycommandsintents- defaults to Guilds, GuildMembers, GuildMessages, MessageContent, DirectMessagespartials- defaults to Message, Channel, Reaction- anything else - passed straight through as normal discord.js
ClientOptions
Put one file per command in commandsPath/<category>/<commandFile>.js.
// commandsPath/tools/ping.js
module.exports = {
name: 'ping',
description: 'Replies with pong',
options: [], // optional, standard discord.js slash command options
devOnly: false, // optional, restrict to devUserIds
permissionsRequired: [], // optional, array of role IDs allowed to use this command
deleted: false, // optional, set true to remove this command from Discord
callback: async (client, interaction) => {
await interaction.reply('pong');
},
};Everything gets registered automatically when client.start() runs. New commands are created, existing ones are only edited if their description or options actually changed, and anything marked deleted: true gets removed from Discord (or just skipped if it was never registered).
Before a command's callback runs, botframe checks:
- It's not being used in DMs (guild only, not removable),
- If
devOnlyis set, the user is indevUserIds, - If
permissionsRequiredis set, the user has at least one of those role IDs.
If callback throws, the error gets logged and the user just sees a generic "something went wrong" reply.
botframe comes with one command by default, /status, which shows the framework version, your bot's version (pulled from your project's package.json), uptime, and client/WebSocket ping. If you define your own local command called status, yours will override the built-in one.
Put handler files in eventsPath/<eventName>/<handlerFile>.js, one folder per Discord.js event name. You can have as many handler files in a folder as you want.
// eventsPath/messageCreate/logMessages.js
module.exports = async (client, message) => {
console.log(`${message.author.tag}: ${message.content}`);
};Handlers within a folder run in alphabetical file order, one after another.
Created by krypton Innovations Originally based on notunderctrl's Discord.js v14 tutorial