import { Client, Events, Message } from "@fluxerjs/core"; import { env } from "@/env"; import { CommandRegistry } from "@/registry/commandRegistry"; import { loadModules } from "@/registry/loadModules"; import { watchCommands } from "@/registry/watchCommands"; import { Logger } from "tslog"; const IS_DEV = process.env.NODE_ENV !== "production"; export class Bot { private client: Client; private registry: CommandRegistry; private readonly logger: Logger; constructor() { this.client = new Client({ intents: 0 }); this.registry = new CommandRegistry(); this.logger = new Logger({ type: "pretty", name: "Bot", }); } registerEvents() { this.client.on(Events.MessageCreate, async (msg: Message) => { await this.registry.handle({ client: this.client }, env.PREFIX, msg); }); this.client.on(Events.Ready, () => { this.logger.info("Sucessfully started the bot!"); }); } async start() { this.logger.info("Starting Hydro..."); await loadModules(this.registry, env.PREFIX); if (IS_DEV) { watchCommands(this.registry, env.PREFIX); } this.registerEvents(); await this.client.login(env.FLUXER_BOT_TOKEN); } }