Manual Setup
Initial setup
To start with lilybird you firstly need to create a new project, in this guide we will be using the template provided by @lilybird/create but you can always use another template generator or make it from scratch.
Installing lilybird
Lilybird is available on the npm registry, therefor it can be downloaded with the package manager of your choice.
bun add lilybirdnpm i lilybirdpnpm i lilybirdyarn add lilybirdFast Setup
The createClient function is a helper provided by lilybird that allows you to spin up a client fast without having to worry about managing the compiler yourself.
If all you want is to spin up a bot and do your stuff this is the way to go, however, if you want full control over your bot skip this section.
Using this helper function will still allow you to use transformers, handlers and other things but it requires every listener to be its own function.
Making your first bot
Making your first bot is extremely simple, however it lacks functionality. All the bot functionality is up to you to implement using the tools provided, we have other guides that can help you with specific problems but we highly recommend that you read the official Discord documentation.
1import { createClient, Intents } from "lilybird";2
3await createClient({4 token: process.env.TOKEN,5 intents: Intents.GUILDS,6 listeners: {7
8 setup: (client) => {9 console.log(`Logged in as: ${client.user.username} (${client.user.id})`)10 }11 }12})In-depth setup
The “client”
In lilybird there is no strong concept of what the client is, the provided Client class is just a convenient wrapper that gets passed around each listener that includes an instance of the REST helpers and the active ws connection, however this is not the strict definition of a Client.
Definition
The Client in lilybird is defined as an object that includes the fields returned by the READY event.
The current interface all client representations should respect is called MockClient (name pending change).
The AOT Compiler
The AOT Compiler in lilybird is one of the things that allows lilybird to provide apis like the transformers without having any impact on performance. Its job its to compile down your listeners and transformers into a simple linear dispatch function that has no useless/redundant checks.
While this is an important piece, the AOT Compiler is not required for lilybird to work, you can always make your own dispatch functions manually.