Skip to main content

EmbedBuilder

Index

Constructors

publicconstructor

Properties

publicreadonlydata

data: APIEmbed

Methods

publicaddFields

  • addFields(...fields: RestOrArray<APIEmbedField>): EmbedBuilder
  • Appends fields to the embed.

    @remarks

    This method accepts either an array of fields or a variable number of field parameters. The maximum amount of fields that can be added is 25.

    @example

    Using an array:

    const fields: APIEmbedField[] = ...;
    const embed = new EmbedBuilder()
    .addFields(fields);
    @example

    Using rest parameters (variadic):

    const embed = new EmbedBuilder()
    .addFields(
    { name: 'Field 1', value: 'Value 1' },
    { name: 'Field 2', value: 'Value 2' },
    );

publicsetAuthor

  • Sets the author of this embed.

publicsetColor

  • Sets the color of this embed.

publicsetDescription

  • Sets the description of this embed.

publicsetFields

  • setFields(...fields: RestOrArray<APIEmbedField>): EmbedBuilder
  • Sets the fields for this embed.

    @remarks

    This method is an alias for EmbedBuilder.spliceFields. More specifically, it splices the entire array of fields, replacing them with the provided fields.

    You can set a maximum of 25 fields.

publicsetFooter

  • Sets the footer of this embed.

publicsetImage

  • Sets the image of this embed.

publicsetThumbnail

  • Sets the thumbnail of this embed.

publicsetTimestamp

  • setTimestamp(timestamp?: null | number | Date): EmbedBuilder
  • Sets the timestamp of this embed.

publicsetTitle

  • Sets the title for this embed.

publicsetURL

  • Sets the URL of this embed.

publicspliceFields

  • spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): EmbedBuilder
  • Removes, replaces, or inserts fields for this embed.

    @remarks

    This method behaves similarly to Array.prototype.splice(). The maximum amount of fields that can be added is 25.

    It’s useful for modifying and adjusting order of the already-existing fields of an embed.

    @example

    Remove the first field:

    embed.spliceFields(0, 1);
    @example

    Remove the first n fields:

    const n = 4;
    embed.spliceFields(0, n);
    @example

    Remove the last field:

    embed.spliceFields(-1, 1);

publictoJSON

  • toJSON(): APIEmbed
  • Serializes this builder to API-compatible JSON data.