Skip to content

Commit

Permalink
create client
Browse files Browse the repository at this point in the history
  • Loading branch information
yorunoken committed Oct 18, 2024
1 parent 16da05b commit 7d3a49a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
});
18 changes: 18 additions & 0 deletions src/listeners/ready.ts
Original file line number Diff line number Diff line change
@@ -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">;

0 comments on commit 7d3a49a

Please sign in to comment.