diff --git a/src/index.ts b/src/index.ts index 87346f6..dd4af07 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,7 @@ import { auth } from "osu-api-extended"; +import { createHandler } from "@lilybird/handlers/simple"; +import { CachingDelegationType, createClient, Intents } from "lilybird"; +import { Channel, Guild, GuildVoiceChannel } from "@lilybird/transformers"; // Log in to osu! // This method will automatically refresh @@ -18,3 +21,21 @@ process.on("unhandledRejection", async (error: Error) => { process.on("uncaughtException", async (error: Error) => { console.error("An uncaught exception was detected:", error); }); + +const listeners = await createHandler({ + dirs: { + listeners: `${import.meta.dir}/listeners`, + }, +}); + +await createClient({ + token: process.env.DISCORD_BOT_TOKEN, + caching: { + transformerTypes: { channel: Channel, guild: Guild, voiceState: GuildVoiceChannel }, + delegate: CachingDelegationType.DEFAULT, + applyTransformers: true, + enabled: { channel: true }, + }, + intents: [Intents.GUILDS, Intents.GUILD_MESSAGES, Intents.MESSAGE_CONTENT, Intents.GUILD_MEMBERS], + ...listeners, +}); diff --git a/src/listeners/ready.ts b/src/listeners/ready.ts new file mode 100644 index 0000000..0a4268a --- /dev/null +++ b/src/listeners/ready.ts @@ -0,0 +1,18 @@ +import type { Event } from "@lilybird/handlers/simple"; +import { loadApplicationCommands, loadPrefixCommands } from "utils/loadCommands"; +import { log } from "utils/logs"; + +export default { + event: "ready", + run: async (client) => { + console.log(`Successfully logged in as ${client.user.username} ✅`); + + console.log("Setting up Logs.."); + await log("Start Sequence: Started the bot."); + + await loadPrefixCommands(); + await log("Start Sequence: Loaded message commands"); + await loadApplicationCommands(client); + await log("Start Sequence: Loaded application commands"); + }, +} satisfies Event<"ready">;