DiscordPHP Documentation

MediaGalleryItem
in package
implements JsonSerializable

Represents an item in a media gallery component.

Tags
link
https://discord.com/developers/docs/interactions/message-components#media-gallery-object-media-gallery-item-structure
since
10.5.0

Table of Contents

Interfaces

JsonSerializable

Properties

$description  : string|null
Description for the gallery item.
$media  : UnfurledMediaItem
Media item for the gallery.
$spoiler  : bool
Whether the gallery item is a spoiler.

Methods

fromAttachment()  : self
Creates a new media gallery item from an attachment.
getDescription()  : string|null
Returns the description for the media item.
getMedia()  : UnfurledMediaItem
Returns the media item.
isSpoiler()  : bool
Returns whether the media item is a spoiler.
jsonSerialize()  : array<string|int, mixed>
{@inheritDoc}
new()  : self
Creates a new media gallery item.
setDescription()  : $this
Sets the description for the media item.
setMedia()  : $this
Sets the media item.
setSpoiler()  : $this
Sets whether the media item is a spoiler.

Properties

$description

Description for the gallery item.

private string|null $description

$spoiler

Whether the gallery item is a spoiler.

private bool $spoiler = false

Methods

fromAttachment()

Creates a new media gallery item from an attachment.

public static fromAttachment(string $filename[, string|null $description = null ][, bool $spoiler = false ]) : self
Parameters
$filename : string

Name of the attachment file.

$description : string|null = null

Description for the media item (max 1024 characters).

$spoiler : bool = false

Whether the media item is a spoiler.

Tags
throws
LengthException

Description exceeds 1024 characters.

Return values
self

getDescription()

Returns the description for the media item.

public getDescription() : string|null
Return values
string|null

isSpoiler()

Returns whether the media item is a spoiler.

public isSpoiler() : bool
Return values
bool

jsonSerialize()

{@inheritDoc}

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

new()

Creates a new media gallery item.

public static new(UnfurledMediaItem|string $media[, string|null $description = null ][, bool $spoiler = false ]) : self
Parameters
$media : UnfurledMediaItem|string

Media item or URL of the media item.

$description : string|null = null

Description for the media item (max 1024 characters).

$spoiler : bool = false

Whether the media item is a spoiler.

Tags
throws
LengthException

Description exceeds 1024 characters.

Return values
self

setDescription()

Sets the description for the media item.

public setDescription(string|null $description) : $this
Parameters
$description : string|null

Description for the media item (max 1024 characters).

Tags
throws
LengthException

Description exceeds 1024 characters.

Return values
$this

setSpoiler()

Sets whether the media item is a spoiler.

public setSpoiler([bool $spoiler = true ]) : $this
Parameters
$spoiler : bool = true

Whether the media item is a spoiler.

Return values
$this

        
On this page

Search results