@shadow-dev/core
Version:
A modular core framework for Discord bot development, providing commands, buttons, menus, middleware, and more.
58 lines (57 loc) • 2.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bot = void 0;
const discord_js_1 = require("discord.js");
const command_1 = require("./command");
const event_1 = require("./event");
const button_1 = require("./button");
const menu_1 = require("./menu");
const plugin_1 = require("./plugin");
const util_1 = require("./util");
class Bot {
constructor(token, intents, debug = false, guildId) {
this.client = new discord_js_1.Client({
intents,
});
this.debug = debug;
this.commandManager = new command_1.CommandManager(this.client, this);
this.eventManager = new event_1.EventManager(this.client);
this.buttonManager = new button_1.ButtonManager(this.client);
this.menuManager = new menu_1.MenuManager(this.client);
this.pluginLoader = new plugin_1.PluginLoader(this);
this.guildId = guildId;
(0, util_1.registerModule)("events", this.eventManager, this.client, this.debug).then(() => {
this.client.login(token).then(async () => {
await this.registerModules();
});
});
}
async registerModules() {
if (this.debug)
console.log("🔍 Registering modules...");
await this.pluginLoader.registerPlugins();
await (0, util_1.registerModule)("commands", this.commandManager, this.client, this.debug);
await (0, util_1.registerModule)("buttons", this.buttonManager, this.client, this.debug);
await (0, util_1.registerModule)("menus", this.menuManager, this.client, this.debug);
await this.commandManager.registerCommands(this.guildId);
console.log(`✅ Successfully loaded ${command_1.CommandManager.getAllCommands().size} commands, ${button_1.ButtonManager.getAllButtons().size} buttons, ${menu_1.MenuManager.getAllMenus().size} menus.`);
if (this.debug)
console.log("✅ All modules registered.");
}
getCommandManager() {
return this.commandManager;
}
getEventManager() {
return this.eventManager;
}
getButtonManager() {
return this.buttonManager;
}
getMenuManager() {
return this.menuManager;
}
getClient() {
return this.client;
}
}
exports.Bot = Bot;