Discord.https - v3.0.16
    Preparing search index...

    Class FileBuilder

    The base component builder that contains common symbols for all sorts of components.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    Constructors

    • Creates a new file from API data.

      Parameters

      Returns FileBuilder

      Creating a file from an API data object:

      const file = new FileBuilder({
      spoiler: true,
      file: {
      url: 'attachment://file.png',
      },
      });

      Creating a file using setters and API data:

      const file = new FileBuilder({
      file: {
      url: 'attachment://image.jpg',
      },
      })
      .setSpoiler(false);

    Properties

    data: Partial<DataType>

    The API data associated with this component.

    Methods

    • Clears the id of this component, defaulting to a default incremented id.

      Returns this

    • Sets the id (not the custom id) for this component.

      Parameters

      • id: number

        The id for this component

      Returns this

    • Sets the spoiler status of this file.

      Parameters

      • Optionalspoiler: boolean

        The spoiler status to use

      Returns this

    • Sets the media URL of this file.

      Parameters

      • url: string

        The URL to use

      Returns this

    • Serializes this builder to API-compatible JSON data.

      Returns APIFileComponent

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