MediaGalleryBuilder

export declare class MediaGalleryBuilder extends ComponentBuilder<APIMediaGalleryComponent>
export declare class MediaGalleryBuilder extends ComponentBuilder<APIMediaGalleryComponent>

No summary provided.

constructor(data?)
Creates a new media gallery from API data.
Example
Creating a media gallery from an API data object:
const mediaGallery = new MediaGalleryBuilder({
items: [
{
description: "Some text here",
media: {
url: 'https://cdn.discordapp.com/embed/avatars/2.png',
},
},
],
});
const mediaGallery = new MediaGalleryBuilder({
items: [
{
description: "Some text here",
media: {
url: 'https://cdn.discordapp.com/embed/avatars/2.png',
},
},
],
});
Example
Creating a media gallery using setters and API data:
const mediaGallery = new MediaGalleryBuilder({
items: [
{
description: "alt text",
media: {
url: 'https://cdn.discordapp.com/embed/avatars/5.png',
},
},
],
})
.addItems(item2, item3);
const mediaGallery = new MediaGalleryBuilder({
items: [
{
description: "alt text",
media: {
url: 'https://cdn.discordapp.com/embed/avatars/5.png',
},
},
],
})
.addItems(item2, item3);
NameTypeOptionalDescription
dataPartial<APIMediaGalleryComponent>YesThe API data to create this container with
ProtectedReadonly
Readonly
items:readonly MediaGalleryItemBuilder[]
The items in this media gallery.
addItems(...input):this
Adds a media gallery item to this media gallery.
NameTypeOptionalDescription
...inputRestOrArray<APIMediaGalleryItem | MediaGalleryItemBuilder | ((builder: MediaGalleryItemBuilder) => MediaGalleryItemBuilder)>NoThe items to add
clearId():this
Clears the id of this component, defaulting to a default incremented id.
Inherited from ComponentBuilder
setId(id):this
Sets the id of this component.
NameTypeOptionalDescription
idnumberNoThe id to use
Inherited from ComponentBuilder
spliceItems(index, deleteCount, ...items):this
Removes, replaces, or inserts media gallery items for this media gallery.
NameTypeOptionalDescription
indexnumberNoThe index to start removing, replacing or inserting items
deleteCountnumberNoThe amount of items to remove
...itemsRestOrArray<APIMediaGalleryItem | MediaGalleryItemBuilder | ((builder: MediaGalleryItemBuilder) => MediaGalleryItemBuilder)>NoThe items to insert
toJSON(validationOverride?):APIMediaGalleryComponent
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
NameTypeOptionalDescription
validationOverridebooleanYesForce validation to run/not run regardless of your global preference