EmbedBuilder
- class EmbedBuilder()
Builder class for constructing rich embed objects. Use the method-chaining API to build, then pass
toJSON()result or the builder itself to send/edit methods.Example
const embed = new discord.EmbedBuilder() .setTitle('Server status') .setDescription('All systems operational.') .setColor(0x57f287);
exported from
lib.weeble.dMethods
-
EmbedBuilder.addField(name: string, value: string, inline: boolean)
EmbedBuilder Append a single field.
- Parameters:
name — – The field name (bold heading).
value — – The field value (body text, supports Markdown).
inline — – Whether the field should render inline with adjacent inline fields.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.addFields(...fields:
EmbedFieldData[])EmbedBuilder Append one or more field data objects.
- Parameters:
fields — – One or more EmbedFieldData objects to append.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.clearFields()
EmbedBuilder Remove all fields from the embed.
-
EmbedBuilder.setAuthor(author:
EmbedAuthorData)EmbedBuilder Set the author section with name, optional URL, and optional icon.
- Parameters:
author — – Object containing the author name, and optionally a URL and icon URL.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setColor(color: number)
EmbedBuilder Set the sidebar color as a 24-bit RGB integer (e.g.
0xFF0000for red).- Parameters:
color — – 24-bit RGB color value.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setDescription(description: string)
EmbedBuilder Set the embed description.
- Parameters:
description — – The description text (supports Markdown).
- Returns:
The builder instance for chaining.
Set the footer with text and optional icon.
- Parameters:
footer — – Object containing footer text and optionally an icon URL.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setImage(image: string |
EmbedMediaData)EmbedBuilder Set the main image. Accepts a URL string or a media data object.
- Parameters:
image — – Direct URL string, or a media data object with url, height, and width.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setThumbnail(thumbnail: string |
EmbedMediaData)EmbedBuilder Set the thumbnail in the top-right corner. Accepts a URL string or a media data object.
- Parameters:
thumbnail — – Direct URL string, or a media data object with url, height, and width.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setTimestamp(timestamp: number | Date)
EmbedBuilder Set the timestamp displayed in the embed footer. Defaults to now when no argument is provided.
- Parameters:
timestamp — – A Date object or Unix timestamp (ms). Omit to use the current time.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setTitle(title: string)
EmbedBuilder Set the embed title.
- Parameters:
title — – The title text to display at the top of the embed.
- Returns:
The builder instance for chaining.
-
EmbedBuilder.setURL(url: string)
EmbedBuilder Set a URL the embed title links to.
- Parameters:
url — – The URL to open when the title is clicked.
- Returns:
The builder instance for chaining.
- EmbedBuilder.toJSON() Record<string, unknown>
Serialize the builder to a plain object ready for Discord’s API.
- Returns:
A plain object suitable for sending to Discord’s API.
-
static EmbedBuilder.from(data: Record<string, unknown>)
EmbedBuilder Create an EmbedBuilder from a raw embed object (e.g. from a stored template).
- Parameters:
data — – Raw embed data object.
- Returns:
A new EmbedBuilder populated with the given data.
-
EmbedBuilder.addField(name: string, value: string, inline: boolean)