Skip to content

Handling Events

Creating a listener

index.ts
import { createClient, Intents } from "lilybird";
import { handler } from "@lilybird/handlers/advanced";
handler.cachePath = `${import.meta.dir}/lily-cache/handler`;
await handler.scanDir(`${import.meta.dir}/events`);
await createClient({
token: process.env.TOKEN,
intents: [Intents.GUILDS],
listeners: {/* your listeners */}
setup: async (client) => {
await handler.loadGlobalCommands(client);
},
listeners: handler.getListenersObject()
})
events/ping.ts
1
import { $listener } from "@lilybird/handlers/advanced";
2
3
$listener({
4
event: "ready",
5
handle: (client) => {
6
console.log("Connected as", client.user.username);
7
}
8
});