MediaGallery

Represents a media gallery component builder. Used to display a collection of media items.

Signature

export declare class MediaGallery extends BaseComponentBuilder<APIMediaGalleryComponent>
JSDoc
Examples
const gallery = new MediaGallery()
 .addItems(
     new MediaGalleryItem().setMedia('https://example.com/image1.png').setDescription('Image 1'),
     new MediaGalleryItem().setMedia('https://example.com/image2.jpg').setSpoiler()
 );

Properties

Methods

setId(id: number): this;

Sets the ID for the media gallery component.

Parameters
id
The ID to set.
Returns

The updated MediaGallery instance.

addItems(...items: RestOrArray<MediaGalleryItem>): this;

Adds items to the media gallery.

Parameters
items
The items to add. Can be a single item, an array of items, or multiple items as arguments.
Returns

The updated MediaGallery instance.

setItems(...items: RestOrArray<MediaGalleryItem>): this;

Sets the items for the media gallery, replacing any existing items.

Parameters
items
The items to set. Can be a single item, an array of items, or multiple items as arguments.
Returns

The updated MediaGallery instance.