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

    Class SectionBuilder

    A builder that creates API-compatible JSON data for a section.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new section from API data.

      Parameters

      Returns SectionBuilder

      Creating a section from an API data object:

      const section = new SectionBuilder({
      components: [
      {
      content: "Some text here",
      type: ComponentType.TextDisplay,
      },
      ],
      accessory: {
      media: {
      url: 'https://cdn.discordapp.com/embed/avatars/3.png',
      },
      }
      });

      Creating a section using setters and API data:

      const section = new SectionBuilder({
      components: [
      {
      content: "# Heading",
      type: ComponentType.TextDisplay,
      },
      ],
      })
      .setPrimaryButtonAccessory(button);

    Properties

    The accessory of this section.

    The components within this section.

    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

    • Serializes this builder to API-compatible JSON data.

      Returns APISectionComponent

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