### Complete setup with client creation and listeners Source: https://lilybird.dev/guides/handling-commands Combines the setup and handleCommand functions into a full client initialization. Creates a client with the setup function and an interactionCreate listener that filters for guild application commands. ```typescript import { InteractionType, createClient, Intents } from "lilybird"; import type { ApplicationCommandInteractionStructure, InteractionStructure, Client, } from "lilybird"; async function setup(client: Client): Promise { // Lets register a command called 'ping' await client.rest.createGlobalApplicationCommand(client.user.id, { name: "ping", description: "pong" }); } async function handleCommand( client: Client, interaction: ApplicationCommandInteractionStructure ): Promise { if (interaction.data.name === "ping") { const { ws, rest } = await client.ping(); await client.rest.createInteractionResponse(interaction.id, interaction.token, { type: InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE, data: { content: `🏓 WebSocket: \`${ws}ms\` | Rest: \`${rest}ms\`` } }); } } await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], // We pass the setup function we created above setup, listeners: { interactionCreate: async (client, payload) => { // We only want to handle guild interactions if (!("guild_id" in payload)) return; // We only want to handle application commands if (payload.type !== InteractionType.APPLICATION_COMMAND) return; await handleCommand(client, payload); } } }); ``` -------------------------------- ### Build and start for production Source: https://lilybird.dev/guides/getting-started Compile and start the bot for production using npm. ```bash npm run build npm run start ``` -------------------------------- ### Start the bot with npm Source: https://lilybird.dev/guides/getting-started Start the bot in normal mode using npm, for JavaScript template. ```bash npm run start ``` -------------------------------- ### Install via pnpm create Source: https://lilybird.dev/guides/getting-started Quickly scaffold a new Lilybird project using pnpm. ```bash pnpm create @lilybird ``` -------------------------------- ### Install via yarn create Source: https://lilybird.dev/guides/getting-started Quickly scaffold a new Lilybird project using yarn. ```bash yarn create @lilybird ``` -------------------------------- ### Install via npm create Source: https://lilybird.dev/guides/getting-started Quickly scaffold a new Lilybird project using npm. ```bash npm create @lilybird ``` -------------------------------- ### Install via bun create Source: https://lilybird.dev/guides/getting-started Quickly scaffold a new Lilybird project using Bun's package manager. ```bash bun create @lilybird ``` -------------------------------- ### Setup handler and create client Source: https://lilybird.dev/modules/handlers/default/events Configures the handler cache path, scans the events directory, and creates the client with the handler's listeners. ```typescript 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() }) ``` -------------------------------- ### Run development mode with npm Source: https://lilybird.dev/guides/getting-started Start the bot in development mode using npm, for TypeScript template. ```bash npm run dev ``` -------------------------------- ### Initialize Lilybird Client Source: https://lilybird.dev/guides/manual-setup Basic setup for creating a Lilybird client instance with a token, intents, and listeners. ```typescript import { createClient, Intents } from "lilybird"; await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: {/* your listeners */} }) ``` -------------------------------- ### Reply to a message using messageCreate listener Source: https://lilybird.dev/guides/receiving-messages This example demonstrates how to set up a messageCreate listener to respond to incoming messages with a reference to the original message. ```typescript import { createClient, Intents } from "lilybird"; await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: { messageCreate: async (client, message) => { await client.rest.createMessage(message.channel_id, { content: "Hii~", message_reference: { message_id: message.id } }); } } }); ``` -------------------------------- ### startThreadInForumOrMediaChannel(channelId, body, files?) Source: https://lilybird.dev/documentation/classes/rest Starts a thread in a forum or media channel. Returns a Promise resolving to a Structure. ```APIDOC ## startThreadInForumOrMediaChannel(channelId, body, files?) ### Description Starts a thread in a forum or media channel. ### Parameters - `channelId` (string) - Required - The ID of the channel. - `body` (ForumMediaThreadJSONParams) - Required - Parameters for starting the thread. - `files` (LilybirdAttachment[]) - Optional - An array of attachments. ### Returns `Promise` ``` -------------------------------- ### Register a global application command with setup API Source: https://lilybird.dev/guides/handling-commands Registers a 'ping' command using client.rest.createGlobalApplicationCommand. This is the recommended way to register commands. ```typescript import type { Client } from "lilybird"; async function setup(client: Client): Promise { // Lets register a command called 'ping' await client.rest.createGlobalApplicationCommand(client.user.id, { name: "ping", description: "pong" }); } ``` -------------------------------- ### Using Tasai library for ANSI coloring Source: https://lilybird.dev/guides/coloring Example of using the Tasai library to colorize message content in a Lilybird messageCreate listener. Requires installing tasai and using the t.red.colorize function inside an ANSI code block. ```typescript import { t } from "tasai"; import { createClient, Intents } from "lilybird"; await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: { messageCreate: async (client, message) => { await client.rest.createMessage(message.channel_id, { content: "Hii~", content: `\`\`\`ansi\n${t.red.colorize("Hii~")}\n\`\`\``, message_reference: { message_id: message.id } }); } } }); ``` -------------------------------- ### startThread(name) Source: https://lilybird.dev/modules/transformers/documentation/classes/message Starts a thread on the message with the given name. Returns a Promise resolving to the new Channel. ```APIDOC ## startThread(name) ### Description Starts a thread on the message with the given name. ### Method startThread ### Parameters - **name** (string) - Required - The name of the thread. ### Returns Promise ### Defined in transformers/src/factories/message.ts:308 ``` -------------------------------- ### Initialize the lilybird handler Source: https://lilybird.dev/modules/handlers/default/application-commands Configures the handler cache path, scans the commands directory, and integrates the handler into the client setup. ```typescript 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}/commands`); await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: {/* your listeners */} setup: async (client) => { await handler.loadGlobalCommands(client); }, listeners: handler.getListenersObject() }) ``` -------------------------------- ### getGatewayBot() Source: https://lilybird.dev/documentation/classes/rest Fetches gateway information for the bot, including session start limits. ```APIDOC ## getGatewayBot() ### Description Fetches gateway information for the bot, including session start limits. ### Method `getGatewayBot(): Promise` ### Parameters None. ### Returns `Promise` - A promise resolving to the gateway bot response. ``` -------------------------------- ### Send an embed with createInteractionResponse Source: https://lilybird.dev/guides/embeds-attachments Shows how to send an embed in response to an application command interaction. The embed is a plain object with `title` and `description`. Requires a `setup` function and a bot token. ```typescript import { InteractionCallbackType, InteractionType, createClient, Intents } from "lilybird"; await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], // We pass the setup function we created above setup, listeners: { interactionCreate: async (client, payload) => { // We only want to handle guild interactions if (!("guild_id" in payload)) return; // We only want to handle application commands if (payload.type !== InteractionType.APPLICATION_COMMAND) return; await client.rest.createInteractionResponse(interaction.id, interaction.token, { type: InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE, data: { embeds: [ { title: "Hello, Embed!", description: "This is an embedded message." } ] } }); } } }); ``` -------------------------------- ### get(type, id) Source: https://lilybird.dev/documentation/interfaces/cachemanagerstructure Retrieves a cache entry for the given type and id. ```APIDOC ## get(type, id) ### Description Retrieves a cache entry for the given type and id. ### Method get ### Parameters - **type** (`CacheElementType`) - Required - The type of cache element. - **id** (`string`) - Required - The identifier of the cache entry. ### Returns `Awaitable>` ``` -------------------------------- ### getGuild(guildId, withCounts) Source: https://lilybird.dev/documentation/classes/rest Gets a guild by ID. Returns a promise resolving to the guild structure. ```APIDOC ## getGuild(guildId, withCounts) ### Description Gets a guild by ID. ### Parameters - `guildId` (string) - Required - The ID of the guild. - `withCounts` (boolean) - Optional - Whether to include member and presence counts. Defaults to `false`. ### Returns `Promise` ``` -------------------------------- ### new Client() Source: https://lilybird.dev/documentation/classes/client Creates a new Client instance with the given options and optional debug function. ```APIDOC ## new Client() ### Description Creates a new Client instance with the given options and optional debug function. ### Method Constructor ### Parameters - `options` (BaseClientOptions) - Required - The options for the client. - `debug`? (DebugFunction) - Optional - A debug function. ### Returns `Client` ### Defined in client.ts:60 ``` -------------------------------- ### new User(client, user) Source: https://lilybird.dev/modules/transformers/documentation/classes/user Creates a new User instance with the given client and user structure. ```APIDOC ## new User(client, user) ### Description Creates a new User instance. ### Parameters - **client** (`Client`) - Required - The client instance. - **user** (`Structure`) - Required - The user structure. ### Returns `User` ### Defined in `transformers/src/factories/user.ts:28` ``` -------------------------------- ### startThreadWithoutMessage(channelId, body) Source: https://lilybird.dev/documentation/classes/rest Starts a thread without an associated message. Returns a Promise resolving to a Structure. ```APIDOC ## startThreadWithoutMessage(channelId, body) ### Description Starts a thread without an associated message. ### Parameters - `channelId` (string) - Required - The ID of the channel. - `body` (ThreadJSONParams) - Required - Parameters for starting the thread. ### Returns `Promise` ``` -------------------------------- ### Create handler and client for message commands Source: https://lilybird.dev/modules/handlers/simple/message-commands Sets up the message command handler by pointing to a directory and then creates a client with the handler's listeners. Requires a TOKEN environment variable and the GUILDS intent. ```typescript 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 }) ``` -------------------------------- ### startThreadFromMessage(channelId, messageId, body) Source: https://lilybird.dev/documentation/classes/rest Starts a thread from an existing message. Returns a Promise resolving to a Structure. ```APIDOC ## startThreadFromMessage(channelId, messageId, body) ### Description Starts a thread from an existing message. ### Parameters - `channelId` (string) - Required - The ID of the channel. - `messageId` (string) - Required - The ID of the message. - `body` (ThreadFromMessageJSONParams) - Required - Parameters for starting the thread. ### Returns `Promise` ``` -------------------------------- ### getGuildApplicationCommands(clientId) Source: https://lilybird.dev/documentation/classes/rest Fetches all application commands for a guild. ```APIDOC ## getGuildApplicationCommands(clientId) ### Description Fetches all application commands for a guild. ### Method `getGuildApplicationCommands(clientId: string): Promise` ### Parameters - `clientId` (string) - Required - The client ID. ### Returns `Promise` - A promise resolving to an array of guild command structures. ``` -------------------------------- ### createGuildApplicationCommand(clientId, guildId, body) Source: https://lilybird.dev/documentation/classes/rest Creates a new application command for a guild. ```APIDOC ## createGuildApplicationCommand(clientId, guildId, body) ### Description Creates a new application command for a guild. ### Method `createGuildApplicationCommand(clientId: string, guildId: string, body: ApplicationCommandJSONParams): Promise` ### Parameters - `clientId` (string) - Required - The client ID. - `guildId` (string) - Required - The guild ID. - `body` (ApplicationCommandJSONParams) - Required - The command data. ### Returns `Promise` - A promise resolving to the created guild command structure. ``` -------------------------------- ### getApplicationEmoji(applicationId, emojiId) Source: https://lilybird.dev/documentation/classes/rest Gets a specific emoji from an application. Returns a promise resolving to the emoji structure. ```APIDOC ## getApplicationEmoji(applicationId, emojiId) ### Description Gets a specific emoji from an application. ### Parameters - `applicationId` (string) - Required - The ID of the application. - `emojiId` (string) - Required - The ID of the emoji. ### Returns `Promise` ``` -------------------------------- ### getGuildApplicationCommands(clientId, withLocalizations) Source: https://lilybird.dev/documentation/classes/rest Fetches all guild application commands with localizations. ```APIDOC ## getGuildApplicationCommands(clientId, withLocalizations) ### Description Fetches all guild application commands with localizations. ### Method `getGuildApplicationCommands(clientId: string, withLocalizations: true): Promise` ### Parameters - `clientId` (string) - Required - The client ID. - `withLocalizations` (true) - Required - Must be true to include localizations. ### Returns `Promise` - A promise resolving to an array of guild command structures. ``` -------------------------------- ### getGuildEmoji(guildId, emojiId) Source: https://lilybird.dev/documentation/classes/rest Gets a specific emoji from a guild. Returns a promise resolving to the emoji structure. ```APIDOC ## getGuildEmoji(guildId, emojiId) ### Description Gets a specific emoji from a guild. ### Parameters - `guildId` (string) - Required - The ID of the guild. - `emojiId` (string) - Required - The ID of the emoji. ### Returns `Promise` ``` -------------------------------- ### getGuildOnboarding(guildId) Source: https://lilybird.dev/documentation/classes/rest Retrieves the onboarding configuration for a guild. Returns a Promise that resolves to an OnboardingStructure. ```APIDOC ## getGuildOnboarding(guildId) ### Description Retrieves the onboarding configuration for a guild. ### Parameters - `guildId` (string) - Required - The ID of the guild. ### Returns `Promise` ``` -------------------------------- ### getGlobalApplicationCommands(clientId, withLocalizations) Source: https://lilybird.dev/documentation/classes/rest Fetches all global application commands with localizations. ```APIDOC ## getGlobalApplicationCommands(clientId, withLocalizations) ### Description Fetches all global application commands with localizations. ### Method `getGlobalApplicationCommands(clientId: string, withLocalizations: true): Promise` ### Parameters - `clientId` (string) - Required - The client ID. - `withLocalizations` (true) - Required - Must be true to include localizations. ### Returns `Promise` - A promise resolving to an array of global command structures. ``` -------------------------------- ### createGlobalApplicationCommand(clientId, body) Source: https://lilybird.dev/documentation/classes/rest Creates a new global application command. ```APIDOC ## createGlobalApplicationCommand(clientId, body) ### Description Creates a new global application command. ### Method `createGlobalApplicationCommand(clientId: string, body: ApplicationCommandJSONParams): Promise` ### Parameters - `clientId` (string) - Required - The client ID. - `body` (ApplicationCommandJSONParams) - Required - The command data. ### Returns `Promise` - A promise resolving to the created command structure. ``` -------------------------------- ### new Guild(client, guild) Source: https://lilybird.dev/modules/transformers/documentation/classes/guild Creates a new Guild instance. The constructor takes a Client and a Structure object representing the guild data. ```APIDOC ## new Guild(client, guild) ### Description Creates a new Guild instance. ### Parameters - **client** (Client) - Required - The client instance. - **guild** (Structure) - Required - The guild structure data. ### Returns Guild ``` -------------------------------- ### login() Source: https://lilybird.dev/documentation/classes/client Logs in the client with the provided token and returns a promise that resolves to a string. ```APIDOC ## login() ### Description Logs in the client with the provided token and returns a promise that resolves to a string. ### Method login ### Parameters - `token` (string) - Required - The authentication token. ### Returns `Promise` ### Defined in client.ts:75 ``` -------------------------------- ### getGuildPruneCount(guildId, params) Source: https://lilybird.dev/documentation/classes/rest Gets the count of members that would be pruned. Accepts parameters for days and include roles. Returns a promise resolving to an object with a pruned count. ```APIDOC ## getGuildPruneCount(guildId, params) ### Description Gets the count of members that would be pruned. ### Parameters - `guildId` (string) - Required - The ID of the guild. - `params` (object) - Required - Query parameters. - `params.days` (number) - Required - Number of days to count prune. - `params.include_roles` (string) - Optional - Roles to include. ### Returns `Promise` - `pruned` (number) - The number of members that would be pruned. ``` -------------------------------- ### createClient(options) Source: https://lilybird.dev/documentation/functions/createclient Creates a new Client instance with the provided options. It is a generic function that supports custom transformers and client options, returning a Promise that resolves to a Client. ```APIDOC ## createClient(options) ### Description Creates a new Client instance with the provided options. It is a generic function that supports custom transformers and client options, returning a Promise that resolves to a Client. ### Signature createClient(options): Promise>> ### Type Parameters - **T** (extends Transformers) - No default - The transformers type. - **O** (extends ClientOptions) - Default: ClientOptions - The client options type. ### Parameters - **options** (O) - Required - The client options to use for creating the client. ### Returns Promise>> - A promise that resolves to a Client instance. ### Defined in client.ts:557 ``` -------------------------------- ### new Channel(client, channel, resolved) Source: https://lilybird.dev/modules/transformers/documentation/classes/channel Creates a new Channel instance. ```APIDOC ## new Channel(client, channel, resolved) ### Description Creates a new Channel instance. ### Constructor `new Channel(client, channel, resolved)` ### Parameters - **client** (`Client`) - The client instance. - **channel** (`Structure`) - The channel structure. - **resolved** (`boolean`) - Whether the channel is resolved. ### Returns `Channel` ### Defined in `transformers/src/factories/channel.ts:76` ``` -------------------------------- ### Args extraction code for message commands Source: https://lilybird.dev/modules/handlers/simple/message-commands Shows how the args parameter is computed: it slices the message content by the prefix length, trims, splits on whitespace, and shifts to get the first argument. ```typescript message.content.slice(this.prefix.length) .trim() .split(/\s+/g) .shift() ``` -------------------------------- ### getGlobalApplicationCommands(clientId) Source: https://lilybird.dev/documentation/classes/rest Fetches all global application commands for a client. ```APIDOC ## getGlobalApplicationCommands(clientId) ### Description Fetches all global application commands for a client. ### Method `getGlobalApplicationCommands(clientId: string): Promise` ### Parameters - `clientId` (string) - Required - The client ID. ### Returns `Promise` - A promise resolving to an array of global command structures. ``` -------------------------------- ### Embed component usage with fields and footer Source: https://lilybird.dev/modules/jsx/embed Use the Embed component to create an embed with a title, color, timestamp, multiple fields, and a footer. The example uses EmbedField with inline prop and EmbedFooter. ```tsx {Array.from({ length: 4 }, (_, i) => ( ))} ``` -------------------------------- ### Custom 4-bit ANSI colorize helper Source: https://lilybird.dev/guides/coloring Helper function to colorize text with 4-bit ANSI SGR codes. Validates codes for foreground (30-37) and background (40-47), uses \x1B for ESC, and resets with 39 or 49. Example usage: colorizeWith4Bit("Hii~", 31). ```typescript function colorizeWith4Bit(string: string, code: number): string { // We do this check first to avoid duplication const isBackgroundColor = code >= 40 && code <= 47; // Is the code a valid 4bit ascii color if (!(code >= 30 && code <= 37) || !isBackgroundColor) return; /* The `ESC` in ANSI represents byte 27, there are a few ways to write this like `\e`, `\033`, `\u001b` and `\x1b` we chose `x1b` because it is the most portable among them. */ return `\x1B[${code}m${string}\x1B[${isBackgroundColor ? 49 : 39}m`; } const redText = colorizeWith4Bit("Hii~", 31); ``` -------------------------------- ### Initialize Event Handler Source: https://lilybird.dev/modules/handlers/simple/events Use createHandler to specify the directory containing your event files and spread the result into the createClient configuration. ```typescript import { createClient, Intents } from "lilybird"; import { createHandler } from "@lilybird/handlers/simple"; const listeners = await createHandler({ dirs: { events: `${import.meta.dir}/events`, } }) await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: {/* your listeners */} ...listeners }) ``` -------------------------------- ### Initialize the command handler Source: https://lilybird.dev/modules/handlers/simple/application-commands Configures the handler by specifying the directory for slash commands and integrates it into the client initialization. ```typescript import { createClient, Intents } from "lilybird"; import { createHandler } from "@lilybird/handlers/simple"; const listeners = await createHandler({ dirs: { slashCommands: `${import.meta.dir}/commands`, } }) await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: {/* your listeners */} ...listeners }) ``` -------------------------------- ### getCurrentApplication() Source: https://lilybird.dev/documentation/classes/rest Retrieves the current application information. ```APIDOC ## getCurrentApplication() ### Description Retrieves the current application information. ### Parameters None ### Returns Promise ``` -------------------------------- ### beginGuildPrune(guildId, body) Source: https://lilybird.dev/documentation/classes/rest Begins a prune operation on a guild. Accepts a body with optional days, compute prune count, include roles, and reason. Returns a promise resolving to an object with a pruned count. ```APIDOC ## beginGuildPrune(guildId, body) ### Description Begins a prune operation on a guild. ### Parameters - `guildId` (string) - Required - The ID of the guild. - `body` (object) - Required - Request body. - `body.days` (number) - Optional - Number of days to prune. - `body.compute_prune_count` (boolean) - Optional - Whether to compute the prune count. - `body.include_roles` (string[]) - Optional - Roles to include. - `body.reason` (string) - Optional - The reason for pruning. ### Returns `Promise` - `pruned` (null | number) - The number of members pruned, or null if not computed. ``` -------------------------------- ### With Transformers Source: https://lilybird.dev/api/transformers Shows how to define a transformer for the ready listener. The transformer receives the client and payload, and the listener only receives the returned value (here, the user id). ```typescript import { createClient, Intents, TransformerReturnType } from "lilybird"; await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], transformers: { ready: { return: TransformerReturnType.SINGLE, // Now the transformers are the ones who receive both the client and payload handler: (client, payload) => { console.log(client.user.id, payload.user.id); return payload.user.id; } } }, listeners: { // And the actually listener only gets the returned value // Which in this example is the user id ready: (id) => { console.log(id); } } }) ``` -------------------------------- ### createGuild(body) Source: https://lilybird.dev/documentation/classes/rest Creates a new guild. Returns a promise resolving to the created guild structure. ```APIDOC ## createGuild(body) ### Description Creates a new guild. ### Parameters - `body` (GuildJSONParams) - Required - The guild parameters. ### Returns `Promise` ``` -------------------------------- ### new MentionChannel(client, channel) Source: https://lilybird.dev/modules/transformers/documentation/classes/mentionchannel Creates a new MentionChannel instance. This constructor is used internally by the library to instantiate a MentionChannel from a client and a MentionStructure. ```APIDOC ## new MentionChannel(client, channel) ### Description Creates a new MentionChannel instance. ### Constructor `new MentionChannel(client, channel)` ### Parameters - `client` (Client) - Required - The client instance. - `channel` (MentionStructure) - Required - The mention channel structure. ### Returns `MentionChannel` ``` -------------------------------- ### new REST(token?) Source: https://lilybird.dev/documentation/classes/rest Creates a new REST instance with an optional token. ```APIDOC ## new REST(token?) ### Description Creates a new REST instance with an optional token. ### Constructor `new REST(token?: string): REST` ### Parameters - `token` (string) - Optional - The authentication token for the Discord API. ### Returns `REST` - A new REST instance. ``` -------------------------------- ### createWebhook(channelId, webhook) Source: https://lilybird.dev/documentation/classes/rest Creates a new webhook in a specified channel. Returns a Promise resolving to a Structure. ```APIDOC ## createWebhook(channelId, webhook) ### Description Creates a new webhook in a specified channel. ### Method POST ### Parameters #### Path Parameters - **channelId** (string) - Required - The ID of the channel. #### Request Body - **webhook** (object) - Required - The webhook data. - **name** (string) - Required - The name of the webhook. - **avatar** (null | ImageData) - Optional - The avatar of the webhook. ### Returns Promise ``` -------------------------------- ### getGuildWelcomeScreen(guildId) Source: https://lilybird.dev/documentation/classes/rest Retrieves the welcome screen for a guild. Returns a Promise that resolves to a WelcomeScreenStructure. ```APIDOC ## getGuildWelcomeScreen(guildId) ### Description Retrieves the welcome screen for a guild. ### Parameters - `guildId` (string) - Required - The ID of the guild. ### Returns `Promise` ``` -------------------------------- ### new ApplicationCommandData() Source: https://lilybird.dev/modules/transformers/documentation/classes/applicationcommanddata Creates a new ApplicationCommandData instance from a DataStructure object. ```APIDOC ## new ApplicationCommandData() ### Description Creates a new ApplicationCommandData instance from a DataStructure object. ### Constructor `new ApplicationCommandData(data): ApplicationCommandData` ### Parameters - `data` (DataStructure) - Required - The data structure to create the instance from. ### Returns `ApplicationCommandData` ### Defined in transformers/src/factories/interaction.ts:477 ``` -------------------------------- ### createStageInstance(instance) Source: https://lilybird.dev/documentation/classes/rest Creates a stage instance. Returns a Promise resolving to a Structure. ```APIDOC ## createStageInstance(instance) ### Description Creates a stage instance. ### Parameters - `instance` (CreateJSONParams) - Required - The stage instance data. ### Returns `Promise` ``` -------------------------------- ### Define a ready event listener Source: https://lilybird.dev/modules/handlers/default/events Registers a listener for the 'ready' event that logs the connected user's username. ```typescript import { $listener } from "@lilybird/handlers/advanced"; $listener({ event: "ready", handle: (client) => { console.log("Connected as", client.user.username); } }); ``` -------------------------------- ### getGlobalApplicationCommand(clientId, commandId) Source: https://lilybird.dev/documentation/classes/rest Fetches a single global application command by ID. ```APIDOC ## getGlobalApplicationCommand(clientId, commandId) ### Description Fetches a single global application command by ID. ### Method `getGlobalApplicationCommand(clientId: string, commandId: string): Promise` ### Parameters - `clientId` (string) - Required - The client ID. - `commandId` (string) - Required - The command ID. ### Returns `Promise` - A promise resolving to the command structure. ``` -------------------------------- ### Multiple listeners via callback in createClient Source: https://lilybird.dev/api/no-events Shows how to call multiple functions from a single interactionCreate listener. Uses the Lilybird client with intents and a token from environment variables. ```typescript import { createClient, Intents } from "lilybird" function useInteraction1(interaction) { console.log(interaction.token); } function useInteraction2(interaction) { console.log(interaction.data); } await createClient({ token: process.env.TOKEN, intents: [Intents.GUILDS], listeners: { interactionCreate: (interaction) => { useInteraction1(interaction); useInteraction2(interaction); } } }) ``` -------------------------------- ### createApplicationEmoji(applicationId, params) Source: https://lilybird.dev/documentation/classes/rest Creates a new emoji for an application. Returns a promise resolving to the created emoji structure. ```APIDOC ## createApplicationEmoji(applicationId, params) ### Description Creates a new emoji for an application. ### Parameters - `applicationId` (string) - Required - The ID of the application. - `params` (object) - Required - The emoji parameters. - `params.name` (string) - Required - The name of the emoji. - `params.image` (ImageData) - Required - The image data for the emoji. ### Returns `Promise` ``` -------------------------------- ### followUp(content, options?) Source: https://lilybird.dev/modules/transformers/documentation/classes/dminteraction Sends a follow-up message to the interaction with the given content and optional options. ```APIDOC ## followUp(content, options?) ### Description Sends a follow-up message to the interaction with the given content and optional options. ### Method followUp ### Parameters - `content` (string) - Required - The content of the follow-up message. - `options`? (InteractionReplyOptions) - Optional - Additional options for the follow-up. ### Returns `Promise` ### Inherited from `Interaction.followUp` ### Defined in transformers/src/factories/interaction.ts:258 ``` -------------------------------- ### createMessage(channelId, body, files?) Source: https://lilybird.dev/documentation/classes/rest Creates a new message in a channel. Takes the channel ID, message body, and optional files, and returns the created message structure. ```APIDOC ## createMessage(channelId, body, files?) ### Description Creates a new message in a channel. ### Parameters - `channelId` (string) - Required - The ID of the channel. - `body` (CreateJSONParams) - Required - The message body. - `files`? (LilybirdAttachment[]) - Optional - An array of attachments. ### Returns `Promise` ``` -------------------------------- ### bulkOverwriteGlobalApplicationCommand(clientId, body) Source: https://lilybird.dev/documentation/classes/rest Bulk overwrites all global application commands. ```APIDOC ## bulkOverwriteGlobalApplicationCommand(clientId, body) ### Description Bulk overwrites all global application commands. ### Method `bulkOverwriteGlobalApplicationCommand(clientId: string, body: ApplicationCommandJSONParams[]): Promise` ### Parameters - `clientId` (string) - Required - The client ID. - `body` (ApplicationCommandJSONParams[]) - Required - An array of command data. ### Returns `Promise` - A promise resolving to an array of the new command structures. ``` -------------------------------- ### createDM Source: https://lilybird.dev/documentation/classes/rest Creates a direct message channel with a user. ```APIDOC ## createDM ### Description Creates a direct message channel with a user. ### Parameters - `userId` (string) - Required - The ID of the user. ### Returns `Promise` ``` -------------------------------- ### reply(content, options?) Source: https://lilybird.dev/modules/transformers/documentation/classes/guildinteraction Replies to the interaction with the given content and optional options. Returns a Promise that resolves when the reply is sent. ```APIDOC ## reply(content, options?) ### Description Replies to the interaction with the given content and optional options. ### Method reply ### Parameters - **content** (string) - Required - The content of the reply. - **options** (InteractionReplyOptions) - Optional - Additional options for the reply. ### Returns Promise ### Inherited from Interaction.reply ### Defined in transformers/src/factories/interaction.ts:113 ``` -------------------------------- ### createGuildSticker Source: https://lilybird.dev/documentation/classes/rest Creates a new sticker in a guild. Requires a guild ID, sticker ID, and parameters including name, description, tags, and file. ```APIDOC ## createGuildSticker ### Description Creates a new sticker in a guild. ### Parameters - `guildId` (string) - Required - The ID of the guild. - `stickerId` (string) - Required - The ID of the sticker. - `params` (object) - Required - The sticker parameters. - `params.name` (string) - Required - The name of the sticker. - `params.description` (string) - Required - The description of the sticker. - `params.tags` (string) - Required - The tags for the sticker. - `params.file` (Blob) - Required - The sticker file. - `params.reason` (string) - Optional - The reason for creation. ### Returns `Promise` ``` -------------------------------- ### executeWebhook(webhookId, token, params, body?, files?) Source: https://lilybird.dev/documentation/classes/rest Executes a webhook by its ID and token. Returns a Promise resolving to null or a Structure. ```APIDOC ## executeWebhook(webhookId, token, params, body?, files?) ### Description Executes a webhook by its ID and token. ### Method POST ### Parameters #### Path Parameters - **webhookId** (string) - Required - The ID of the webhook. - **token** (string) - Required - The token of the webhook. #### Query Parameters - **wait** (boolean) - Optional - Whether to wait for the message to be sent. - **thread_id** (string) - Optional - The ID of the thread to send the message to. #### Request Body - **body** (ExecuteWebhookJSONParams) - Optional - The message payload. - **files** (LilybirdAttachment[]) - Optional - The files to attach. ### Returns Promise ``` -------------------------------- ### reply(content, options?) Source: https://lilybird.dev/modules/transformers/documentation/classes/dminteraction Replies to the interaction with the given content and optional options. ```APIDOC ## reply(content, options?) ### Description Replies to the interaction with the given content and optional options. ### Method reply ### Parameters - `content` (string) - Required - The content of the reply. - `options`? (InteractionReplyOptions) - Optional - Additional options for the reply. ### Returns `Promise` ### Inherited from `Interaction.reply` ### Defined in transformers/src/factories/interaction.ts:113 ``` -------------------------------- ### bulkOverwriteGuildApplicationCommand(clientId, guildId, body) Source: https://lilybird.dev/documentation/classes/rest Bulk overwrites guild application commands. Returns a Promise resolving to an array of GuildStructure. ```APIDOC ## bulkOverwriteGuildApplicationCommand(clientId, guildId, body) ### Description Bulk overwrites guild application commands. ### Parameters - **clientId** (string) - Required - The client ID. - **guildId** (string) - Required - The guild ID. - **body** (ApplicationCommandJSONParams[]) - Required - An array of command parameters. ### Returns Promise ``` -------------------------------- ### Create a Role Select Menu Source: https://lilybird.dev/modules/jsx/components Demonstrates the usage of a RoleSelectMenu component inside an ActionRow. ```typescript import { ActionRow, RoleSelectMenu } from "@lilybird/jsx"; const selectRow = ( ); ``` -------------------------------- ### createGuildFromGuildTemplate(templateCode, guild) Source: https://lilybird.dev/documentation/classes/rest Creates a guild from a guild template. Takes the template code and guild data, and returns the created guild structure. ```APIDOC ## createGuildFromGuildTemplate(templateCode, guild) ### Description Creates a guild from a guild template. ### Parameters - `templateCode` (string) - Required - The code of the template. - `guild` (object) - Required - The guild data. - `guild.name` (string) - Required - The name of the guild. - `guild.image`? (ImageData) - Optional - The guild image. ### Returns `Promise` ``` -------------------------------- ### Create Link Buttons Source: https://lilybird.dev/modules/jsx/components Shows how to include a link button alongside a standard button. Note that link buttons require a url property instead of a custom_id. ```typescript import { ActionRow, Button } from "@lilybird/jsx"; import { ButtonStyle } from "lilybird"; const buttonRow = (