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.
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})
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