class SectionBuilder

external
declare class SectionBuilder extends ComponentBuilder<APISectionComponent>

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

Constructors

constructor()

Creates a new section from API data.

Examples: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);

readonlyoptionalexternal
accessory? : ButtonBuilder | ThumbnailBuilder

The accessory of this section.

readonlyexternal
components : ComponentBuilder[]

The components within this section.

readonlyexternal
data : Partial<APISectionComponent>

The API data associated with this component.

Inherited from: ComponentBuilder

external
addTextDisplayComponents() : this

Adds text display components to this section.

external
clearId() : this

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

Inherited from: ComponentBuilder

external
setButtonAccessory() : this

Sets the accessory of this section to a button.

external
setId(
id: number
) : this

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

Inherited from: ComponentBuilder

external
setThumbnailAccessory() : this

Sets the accessory of this section to a thumbnail.

external
spliceTextDisplayComponents() : this

Removes, replaces, or inserts text display components for this section.

external
toJSON() : APISectionComponent

Serializes this builder to API-compatible JSON data.