Something went wrong. Try again.
Yet another Fluxer bot built with TypeScript and Bun
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import { 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<Bot>;
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); }}