cocoa-discord - v3.2.0
    Preparing search index...

    Class CocoaEmbed

    Extended EmbedBuilder with addInlineFields. This allow you to save a line of inline: true

    Hierarchy

    • EmbedBuilder
      • CocoaEmbed
    Index

    Constructors

    • Parameters

      • Optionaldata: APIEmbed | EmbedData

      Returns CocoaEmbed

    Properties

    data: APIEmbed

    The API data associated with this embed.

    Accessors

    • get length(): number

      Returns number

    Methods

    • Appends fields to the embed.

      Parameters

      • ...fields: RestOrArray<APIEmbedField>

        The fields to add

      Returns this

      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.

      Using an array:

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

      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

      • options: null | EmbedAuthorOptions

        The options to use

      Returns this

    • Sets the color of this embed.

      Parameters

      • color: null | ColorResolvable

        The color to use

      Returns this

    • Sets the description of this embed.

      Parameters

      • description: null | string

        The description to use

      Returns this

    • Sets the fields for this embed.

      Parameters

      • ...fields: RestOrArray<APIEmbedField>

        The fields to set

      Returns this

      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.

    • Sets the footer of this embed.

      Parameters

      • options: null | EmbedFooterOptions

        The footer to use

      Returns this

    • Sets the image of this embed.

      Parameters

      • url: null | string

        The image URL to use

      Returns this

    • Sets the thumbnail of this embed.

      Parameters

      • url: null | string

        The thumbnail URL to use

      Returns this

    • Sets the timestamp of this embed.

      Parameters

      • Optionaltimestamp: null | number | Date

        The timestamp or date to use

      Returns this

    • Sets the title for this embed.

      Parameters

      • title: null | string

        The title to use

      Returns this

    • Sets the URL of this embed.

      Parameters

      • url: null | string

        The URL to use

      Returns this

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

      Parameters

      • index: number

        The index to start at

      • deleteCount: number

        The number of fields to remove

      • ...fields: APIEmbedField[]

        The replacing field objects

      Returns this

      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.

      Remove the first field:

      embed.spliceFields(0, 1);
      

      Remove the first n fields:

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

      Remove the last field:

      embed.spliceFields(-1, 1);
      
    • Serializes this builder to API-compatible JSON data.

      Returns APIEmbed

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

    • Parameters

      • other: APIEmbed | JSONEncodable<APIEmbed>

      Returns EmbedBuilder