solara-testing-beta
Version:
A modern, customizable, and lightweight Discord framework.
65 lines âĸ 2.95 kB
JavaScript
;
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