UNPKG

solara-testing-beta

Version:

A modern, customizable, and lightweight Discord framework.

65 lines â€ĸ 2.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const discord_js_1 = require("discord.js"); const CommandHandler_1 = require("./CommandHandler"); const FunctionManager_1 = require("./FunctionManager"); const FunctionParser_1 = require("./FunctionParser"); const loader_1 = require("../utils/loader"); class SolaraClient extends discord_js_1.Client { solaraOptions; commandHandler; functionManager; functionParser; constructor(options) { const defaultIntents = [ discord_js_1.GatewayIntentBits.Guilds, discord_js_1.GatewayIntentBits.GuildMessages, discord_js_1.GatewayIntentBits.MessageContent, discord_js_1.GatewayIntentBits.GuildMembers, ]; const defaultPartials = [discord_js_1.Partials.Channel, discord_js_1.Partials.Message, discord_js_1.Partials.User, discord_js_1.Partials.GuildMember]; const clientOptions = { intents: options.intents ?? defaultIntents, partials: options.partials ?? defaultPartials, ...Object.fromEntries(Object.entries(options).filter(([key]) => !['intents', 'partials', 'prefix', 'commandDirs', 'functionDirs', 'eventDirs', 'developerIds', 'token'].includes(key))) }; super(clientOptions); this.solaraOptions = options; this.commandHandler = new CommandHandler_1.CommandHandler(this); this.functionManager = new FunctionManager_1.FunctionManager(this); this.functionParser = new FunctionParser_1.FunctionParser(this); } async start() { console.log("🚀 Initializing Solara Client..."); if (this.solaraOptions.functionDirs) { const loadedFunctions = await (0, loader_1.loadFunctions)(this.solaraOptions.functionDirs); loadedFunctions.forEach(func => this.functionManager.addFunction(func)); console.log(`✅ Loaded ${this.functionManager.functions.size} functions.`); } else { console.log("â„šī¸ No function directories specified."); } if (this.solaraOptions.commandDirs) { await this.commandHandler.loadCommands(this.solaraOptions.commandDirs); } else { console.log("â„šī¸ No command directories specified."); await this.commandHandler.loadCommands(); } const defaultEventDirs = ['src/handlers']; const eventDirs = this.solaraOptions.eventDirs ? [...defaultEventDirs, ...this.solaraOptions.eventDirs] : defaultEventDirs; await (0, loader_1.loadEvents)(this, eventDirs); try { console.log("âŗ Logging in..."); await this.login(this.solaraOptions.token); } catch (error) { console.error('❌ Login Failed:', error); process.exit(1); } } } exports.default = SolaraClient; //# sourceMappingURL=SolaraClient.js.map