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

Let’s create a simple ping command to demonstrate how it works.

index.ts
import { createClient, Intents } from "lilybird";
import { createHandler } from "@lilybird/handlers/simple";
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/simple";
export default {
name: "ping",
run: async (message, args) => {
const { ws, rest } = await message.client.ping();
await message.reply({
content: `πŸ“ WebSocket: \`${ws}ms\` | Rest: \`${rest}ms\``
});
},
} satisfies MessageCommand