EmbedBuilder
EmbedBuilder creates Discord embed payloads using a chainable API. All limits (title length, field count, total character count) are validated before toJSON() is called.
Import
Section titled “Import”import { EmbedBuilder } from "lunibee";// or from the sub-package:import { EmbedBuilder } from "@lunibee/builders";import { EmbedBuilder } from "lunibee";// or from the sub-package:import { EmbedBuilder } from "@lunibee/builders";Methods
Section titled “Methods”All methods return this for chaining.
setTitle(title)
Section titled “setTitle(title)”Sets the embed title (max 256 characters).
embed.setTitle("Server Status 🐝");embed.setTitle("Server Status 🐝");setDescription(description)
Section titled “setDescription(description)”Sets the embed description (max 4096 characters).
embed.setDescription("All systems operational.");embed.setDescription("All systems operational.");setColor(color)
Section titled “setColor(color)”Sets the embed accent color as a hex integer.
embed.setColor(0xf59e0b); // amberembed.setColor(0x5865f2); // Discord blurpleembed.setColor(0xed4245); // redembed.setColor(0xf59e0b); // amberembed.setColor(0x5865f2); // Discord blurpleembed.setColor(0xed4245); // redsetURL(url)
Section titled “setURL(url)”Makes the title a hyperlink.
embed.setURL("https://lunibee.js.org");embed.setURL("https://lunibee.js.org");setTimestamp(date?)
Section titled “setTimestamp(date?)”Adds a timestamp. Defaults to now if no date is passed.
embed.setTimestamp();embed.setTimestamp(new Date("2024-01-01"));embed.setTimestamp();embed.setTimestamp(new Date("2024-01-01"));setAuthor(options)
Section titled “setAuthor(options)”Sets the embed author.
embed.setAuthor({ name: "Lunibee Bot", iconURL: "https://example.com/icon.png", url: "https://lunibee.js.org",});embed.setAuthor({ name: "Lunibee Bot", iconURL: "https://example.com/icon.png", url: "https://lunibee.js.org",});setFooter(options)
Section titled “setFooter(options)”Sets the embed footer.
embed.setFooter({ text: "Powered by Lunibee 🐝", iconURL: "https://example.com/icon.png" });embed.setFooter({ text: "Powered by Lunibee 🐝", iconURL: "https://example.com/icon.png" });setThumbnail(url)
Section titled “setThumbnail(url)”Sets the thumbnail (small image on the top-right).
embed.setThumbnail(user.displayAvatarURL({ size: 128 }));embed.setThumbnail(user.displayAvatarURL({ size: 128 }));setImage(url)
Section titled “setImage(url)”Sets the large embed image.
embed.setImage("https://example.com/banner.png");embed.setImage("https://example.com/banner.png");addFields(...fields)
Section titled “addFields(...fields)”Adds one or more fields (max 25 total, each name ≤ 256 chars, value ≤ 1024 chars).
embed.addFields( { name: "Ping", value: "24ms", inline: true }, { name: "Uptime", value: "48h", inline: true }, { name: "Guilds", value: "1,234", inline: true },);embed.addFields( { name: "Ping", value: "24ms", inline: true }, { name: "Uptime", value: "48h", inline: true }, { name: "Guilds", value: "1,234", inline: true },);spliceFields(index, deleteCount, ...fields)
Section titled “spliceFields(index, deleteCount, ...fields)”Replaces or removes fields at a given index.
toJSON()
Section titled “toJSON()”Serializes the embed to a raw Discord API-compatible object.
const payload = embed.toJSON();// Use in: channel.send({ embeds: [embed] })const payload = embed.toJSON();// Use in: channel.send({ embeds: [embed] })Full Example
Section titled “Full Example”import { EmbedBuilder } from "lunibee";
const embed = new EmbedBuilder() .setTitle("Moderation Log 🔨") .setDescription("A member was banned from the server.") .setColor(0xed4245) .setAuthor({ name: "AutoMod", iconURL: "https://example.com/automod.png" }) .addFields( { name: "User", value: `<@${bannedUserId}>`, inline: true }, { name: "Reason", value: banReason, inline: true }, { name: "Moderator", value: `<@${modId}>`, inline: false }, ) .setTimestamp() .setFooter({ text: "Lunibee Moderation" });
await logChannel.send({ embeds: [embed] });import { EmbedBuilder } from "lunibee";
const embed = new EmbedBuilder() .setTitle("Moderation Log 🔨") .setDescription("A member was banned from the server.") .setColor(0xed4245) .setAuthor({ name: "AutoMod", iconURL: "https://example.com/automod.png" }) .addFields( { name: "User", value: `<@${bannedUserId}>`, inline: true }, { name: "Reason", value , inline: true }, { name: "Moderator", value: `<@${modId}>`, inline: false }, ) .setTimestamp() .setFooter({ text: "Lunibee Moderation" });
await logChannel.send({ embeds: [embed] });Limits
Section titled “Limits”| Property | Limit |
|---|---|
| Title | 256 characters |
| Description | 4,096 characters |
| Field name | 256 characters |
| Field value | 1,024 characters |
| Fields | 25 |
| Footer text | 2,048 characters |
| Author name | 256 characters |
| Total embed characters | 6,000 |