Class in Builders and Formatting · JavaScript & TypeScript
Assemble an embed by chaining methods, then pass the builder or build()'s plain object in a message operation's embeds
A message operation builds a supplied builder once when it reads its input, so later changes do not affect that operation. Setters change this builder and return it so calls can be chained. Later setters replace earlier values, while field methods append. Every build returns a fresh object, including copied author, footer, media and field objects. The builder reads supported properties by name, including inherited properties and getters that do not appear in normal key lists. Values that are not objects and unknown own enumerable fields remain for the message operation to validate. Building sends nothing. Only color and timestamp convert their input, throwing Helper for input they cannot convert. The field method throws Configuration for options that are not an object with an optional boolean inline. Message operations check lengths, URLs and server limits
class EmbedBuilderConstructor#
new EmbedBuilder(): EmbedBuilderMethods#
addFields #
Add field objects after existing fields in argument order and return this builder
Copies each object, passing no arguments adds nothing
addFields(...values: readonly EmbedFieldInput[]): thisaddFields(
...values:
readonly EmbedFieldInput[]
): thisParameters
...values-
readonly EmbedFieldInput[]
- Returns
this
author#
Replace the author label and optional links, copy the supplied object, then return this builder
author(value: EmbedAuthorInput): thisauthor(
value: EmbedAuthorInput
): thisParameters
value-
EmbedAuthorInput
- Returns
this
build#
Return a fresh plain input snapshot for messages, messages or messages
This method performs no URL, length, attachment or provider-limit validation
build(): EmbedInput- Returns
EmbedInput
color#
Replace the color and return this builder
Accepts any Color, such as 0xff8800, "#ff8800" or [255, 136, 0], converted with colors. Input that cannot be converted throws Helper with operation embed
color(value: ColorInput): thisParameters
value-
ColorInput
- Returns
this
description#
Replace the body text and return this builder
Message operations enforce the 4096-character limit
description(value: string): thisParameters
value-
string
- Returns
this
field#
Add a named section after existing fields and return this builder
Set options to true to request side-by-side display. It defaults to false when the message is sent. Options that are not an object, or an inline value that is not a boolean, throw Configuration
field(
name: string,
value: string,
options?: EmbedFieldOptions
): thisfield(
name: string,
value: string,
options?: EmbedFieldOptions
): thisParameters
name-
string value-
string optionsoptional-
EmbedFieldOptions
- Returns
this
footer#
Replace the footer text and optional icon, copy the supplied object, then return this builder
footer(value: EmbedFooterInput): thisfooter(
value: EmbedFooterInput
): thisParameters
value-
EmbedFooterInput
- Returns
this
image#
Replace the full-size image URL and optional alternative text, copy the object, then return this builder
No image is uploaded or fetched
image(value: EmbedMediaInput): thisParameters
value-
EmbedMediaInput
- Returns
this
thumbnail#
Replace the small image URL and optional alternative text, copy the object, then return this builder
No image is uploaded or fetched
thumbnail(value: EmbedMediaInput): thisthumbnail(
value: EmbedMediaInput
): thisParameters
value-
EmbedMediaInput
- Returns
this
timestamp#
Replace the embed's timestamp and return this builder
Accepts a Date, Unix epoch milliseconds or an ISO 8601 string with a timezone. A Date or number is converted with to, and a string is kept for the message operation to validate. An invalid Date or a number outside the Date range throws Helper with operation embed
timestamp(value: string | number | Date): thistimestamp(
value: string | number | Date
): thisParameters
value-
string | number | Date
- Returns
this
title#
Replace the title text and return this builder
Message operations enforce the 256-character limit
title(value: string): thisParameters
value-
string
- Returns
this
url#
Replace the destination opened from the title and return this builder
The URL is not checked or fetched here
url(value: string): thisParameters
value-
string
- Returns
this