Skip to content

Handling Message Commands

Currently the @lilybird/handlers package provides only one way of handling application commands however i can assure you there are more to come.

Creating a simple command

Lets create a simple ping command to show how it works.

index.ts
import { createClient, Intents } from "lilybird";
import { createHandler } from "@lilybird/handlers";
const listeners = await createHandler({
dirs: {
messageCommands: `${import.meta.dir}/commands`,
}
})
await createClient({
token: process.env.TOKEN,
intents: [Intents.GUILDS],
listeners: {/* your listeners */}
...listeners
})
commands/ping.ts
import { MessageCommand } from "@lilybird/handlers";
export default {
name: "ping",
run: async (message, args) => {
const { ws, rest } = await message.client.ping();
await message.edit({
content: `🏓 WebSocket: \`${ws}ms\` | Rest: \`${rest}ms\``
});
},
} satisfies MessageCommand