Class EmbedBuilder

Hierarchy

  • EmbedBuilder
    • EmbedBuilder

Constructors

Properties

data: APIEmbed

The API data associated with this embed.

Accessors

  • get length(): number
  • Returns number

Methods

  • Appends fields to the embed.

    Parameters

    Returns EmbedBuilder

    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' },
    );
  • Sets the author of this embed.

    Parameters

    Returns EmbedBuilder

  • Sets the description of this embed.

    Parameters

    • description: null | string

      The description to use

    Returns EmbedBuilder

  • Sets the fields for this embed.

    Parameters

    Returns EmbedBuilder

    Remarks

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

    You can set a maximum of 25 fields.

  • Sets the footer of this embed.

    Parameters

    Returns EmbedBuilder

  • Sets the image of this embed.

    Parameters

    • url: null | string

      The image URL to use

    Returns EmbedBuilder

  • Sets the thumbnail of this embed.

    Parameters

    • url: null | string

      The thumbnail URL to use

    Returns EmbedBuilder

  • Sets the timestamp of this embed.

    Parameters

    • Optional timestamp: null | number | Date

      The timestamp or date to use

    Returns EmbedBuilder

  • Sets the title for this embed.

    Parameters

    • title: null | string

      The title to use

    Returns EmbedBuilder

  • Sets the URL of this embed.

    Parameters

    • url: null | string

      The URL to use

    Returns EmbedBuilder

  • Removes, replaces, or inserts fields for this embed.

    Parameters

    • index: number

      The index to start at

    • deleteCount: number

      The number of fields to remove

    • Rest ...fields: APIEmbedField[]

      The replacing field objects

    Returns EmbedBuilder

    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);
    
  • Serializes this builder to API-compatible JSON data.

    Returns APIEmbed

    Remarks

    This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.

Generated using TypeDoc