Documentation

Embed extends Part

An embed object to be sent with a message.

Table of Contents

TYPE_ARTICLE  = 'article'
TYPE_GIFV  = 'gifv'
TYPE_IMAGE  = 'image'
TYPE_LINK  = 'link'
TYPE_RICH  = 'rich'
TYPE_VIDEO  = 'video'
$author  : Author
$color  : int
$created  : bool
Is the part already created in the Discord servers?
$description  : string
$fields  : Collection|array<string|int, Field>
$footer  : Footer
$image  : Image
$provider  : array<string|int, mixed>
$scriptData  : mixed
Custom script data.
$thumbnail  : Image
$timestamp  : Carbon|string
$title  : string
$type  : string
$url  : string
$video  : Video
$attributes  : array<string|int, mixed>
The parts attributes.
$discord  : Discord
The Discord client.
$factory  : Factory
The factory.
$fillable  : array<string|int, mixed>
The parts fillable attributes.
$fillAfterSave  : bool
Should we fill the part after saving?
$hidden  : array<string|int, mixed>
Attributes that are hidden from debug info.
$http  : Http
The HTTP client.
$regex  : string
The regex pattern to replace variables with.
$repositories  : array<string|int, mixed>
An array of repositories that can exist in a part.
$repositories_cache  : array<string|int, mixed>
An array of repositories.
__construct()  : mixed
Create a new part instance.
__debugInfo()  : array<string|int, mixed>
Handles debug calls from var_dump and similar functions.
__get()  : mixed
Handles dynamic get calls onto the part.
__set()  : mixed
Handles dynamic set calls onto the part.
__toString()  : string
Converts the part to a string.
addField()  : $this
Adds a field to the embed.
addFieldValues()  : $this
Adds a field to the embed with values.
fetch()  : ExtendedPromiseInterface<string|int, static>
Fetches any missing information about the part from Discord's servers.
fill()  : void
Fills the parts attributes from an array.
getCreatableAttributes()  : array<string|int, mixed>
Returns the attributes needed to create.
getPublicAttributes()  : array<string|int, mixed>
Returns an array of public attributes.
getRawAttributes()  : array<string|int, mixed>
Returns an array of raw attributes.
getRepositoryAttributes()  : array<string|int, mixed>
Gets the attributes to pass to repositories.
getUpdatableAttributes()  : array<string|int, mixed>
Returns the updatable attributes.
isPartial()  : bool
Whether the part is considered partial i.e. missing information which can be fetched from Discord.
jsonSerialize()  : array<string|int, mixed>
Provides data when the part is encoded into JSON. Used for JsonSerializable.
offsetExists()  : bool
Checks if an attribute exists via key. Used for ArrayAccess.
offsetGet()  : mixed
Gets an attribute via key. Used for ArrayAccess.
offsetSet()  : mixed
Sets an attribute via key. Used for ArrayAccess.
offsetUnset()  : mixed
Unsets an attribute via key. Used for ArrayAccess.
serialize()  : string
Serializes the data. Used for Serializable.
setAuthor()  : $this
Set the author of this embed.
setColor()  : $this
Sets the color of the embed.
setDescription()  : $this
Sets the description of the embed.
setFooter()  : $this
Set the footer of this embed.
setImage()  : $this
Set the image of this embed.
setThumbnail()  : $this
Set the thumbnail of this embed.
setTimestamp()  : $this
Set the timestamp of this embed.
setTitle()  : $this
Sets the title of the embed.
setType()  : $this
Sets the type of the embed.
setURL()  : $this
Set the URL of this embed.
unserialize()  : mixed
Unserializes some data and stores it. Used for Serializable.
afterConstruct()  : void
Called after the part has been constructed.
exceedsOverallLimit()  : bool
Checks to see if adding a property has put us over Discord's 6000-char overall limit.
getAuthorAttribute()  : Author
Gets the author attribute.
getFieldsAttribute()  : Collection|array<string|int, Field>
Gets the fields attribute.
getFooterAttribute()  : Footer
Gets the footer attribute.
getImageAttribute()  : Image
Gets the image attribute.
getThumbnailAttribute()  : Image
Gets the thumbnail attribute.
getTimestampAttribute()  : Carbon
Gets the timestamp attribute.
getVideoAttribute()  : Video
Gets the video attribute.
resolveColor()  : int
Resolves a color to an integer.
setColorAttribute()  : mixed
Sest the color of this embed.
setDescriptionAttribute()  : mixed
Sets the description of this embed.
setFieldsAttribute()  : mixed
Sets the fields attribute.
setTitleAttribute()  : $this
Set the title of this embed.
setTypeAttribute()  : mixed
Sets the type of the embed.
attributeHelper()  : mixed
Helps with getting embed attributes.
checkForMutator()  : string|false
Checks if there is a mutator present.
getAttribute()  : mixed
Gets an attribute on the part.
getEmbedTypes()  : array<string|int, mixed>
Returns all possible embed types.
setAttribute()  : void
Sets an attribute on the part.

Constants

TYPE_ARTICLE

public mixed TYPE_ARTICLE = 'article'

TYPE_GIFV

public mixed TYPE_GIFV = 'gifv'

TYPE_IMAGE

public mixed TYPE_IMAGE = 'image'
public mixed TYPE_LINK = 'link'

TYPE_RICH

public mixed TYPE_RICH = 'rich'

TYPE_VIDEO

public mixed TYPE_VIDEO = 'video'

Properties

$color

public int $color

The color of the embed.

$created

Is the part already created in the Discord servers?

public bool $created = false

$description

public string $description

A description of the embed.

$provider

public array<string|int, mixed> $provider

The provider of the embed.

$scriptData

Custom script data.

public mixed $scriptData

Used for storing custom information, used by end products.

$thumbnail

public Image $thumbnail

The thumbnail of the embed.

$timestamp

public Carbon|string $timestamp

A timestamp of the embed.

$title

public string $title

The title of the embed.

$type

public string $type

The type of the embed.

$url

public string $url

The URL of the embed.

$attributes

The parts attributes.

protected array<string|int, mixed> $attributes = []

$fillable

The parts fillable attributes.

protected array<string|int, mixed> $fillable = ['title', 'type', 'description', 'url', 'timestamp', 'color', 'footer', 'image', 'thumbnail', 'video', 'provider', 'author', 'fields']

$fillAfterSave

Should we fill the part after saving?

protected bool $fillAfterSave = true

$hidden

Attributes that are hidden from debug info.

protected array<string|int, mixed> $hidden = []

$http

The HTTP client.

protected Http $http

$regex

The regex pattern to replace variables with.

protected string $regex = '/:([a-z_]+)/'

$repositories

An array of repositories that can exist in a part.

protected array<string|int, mixed> $repositories = []

$repositories_cache

An array of repositories.

protected array<string|int, mixed> $repositories_cache = []

Methods

__construct()

Create a new part instance.

public __construct(Discord $discord[, array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : mixed
Parameters
$discord : Discord

The Discord client.

$attributes : array<string|int, mixed> = []

An array of attributes to build the part.

$created : bool = false

Whether the part has already been created.

Return values
mixed

__debugInfo()

Handles debug calls from var_dump and similar functions.

public __debugInfo() : array<string|int, mixed>
Tags
throws
Exception
see
self::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

__get()

Handles dynamic get calls onto the part.

public __get(string $key) : mixed
Parameters
$key : string

The attributes key.

Tags
throws
Exception
see
self::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

The value of the attribute.

__set()

Handles dynamic set calls onto the part.

public __set(string $key, mixed $value) : mixed
Parameters
$key : string

The attributes key.

$value : mixed

The attributes value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
mixed

__toString()

Converts the part to a string.

public __toString() : string
Tags
throws
Exception
see
self::getPublicAttributes()

This function encodes getPublicAttributes into JSON.

Return values
string

A JSON string of attributes.

addField()

Adds a field to the embed.

public addField(mixed ...$fields) : $this
Parameters
$fields : mixed
Tags
throws
RangeException
Return values
$this

addFieldValues()

Adds a field to the embed with values.

public addFieldValues(string $name, string $value[, bool $inline = false ]) : $this
Parameters
$name : string

Maximum length is 256 characters.

$value : string

Maximum length is 1024 characters.

$inline : bool = false

Whether this field gets shown with other inline fields on one line.

Tags
throws
RangeException
Return values
$this

fetch()

Fetches any missing information about the part from Discord's servers.

public fetch() : ExtendedPromiseInterface<string|int, static>
Tags
throws
RuntimeException

The part is not fetchable.

Return values
ExtendedPromiseInterface<string|int, static>

fill()

Fills the parts attributes from an array.

public fill(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>

An array of attributes to build the part.

Return values
void

getCreatableAttributes()

Returns the attributes needed to create.

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

getPublicAttributes()

Returns an array of public attributes.

public getPublicAttributes() : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

An array of public attributes.

getRawAttributes()

Returns an array of raw attributes.

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

Raw attributes.

getRepositoryAttributes()

Gets the attributes to pass to repositories.

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

Attributes.

getUpdatableAttributes()

Returns the updatable attributes.

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

isPartial()

Whether the part is considered partial i.e. missing information which can be fetched from Discord.

public isPartial() : bool
Return values
bool

jsonSerialize()

Provides data when the part is encoded into JSON. Used for JsonSerializable.

public jsonSerialize() : array<string|int, mixed>
Tags
throws
Exception
see
self::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

offsetExists()

Checks if an attribute exists via key. Used for ArrayAccess.

public offsetExists(string $key) : bool
Parameters
$key : string

The attribute key.

Return values
bool

Whether the offset exists.

offsetGet()

Gets an attribute via key. Used for ArrayAccess.

public offsetGet(string $key) : mixed
Parameters
$key : string

The attribute key.

Tags
throws
Exception
see
self::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

offsetSet()

Sets an attribute via key. Used for ArrayAccess.

public offsetSet(string $key, mixed $value) : mixed
Parameters
$key : string

The attribute key.

$value : mixed

The attribute value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
mixed

offsetUnset()

Unsets an attribute via key. Used for ArrayAccess.

public offsetUnset(string $key) : mixed
Parameters
$key : string

The attribute key.

Return values
mixed

serialize()

Serializes the data. Used for Serializable.

public serialize() : string
Return values
string

A string of serialized data.

setAuthor()

Set the author of this embed.

public setAuthor(string $name[, string $iconurl = '' ][, string $url = '' ]) : $this
Parameters
$name : string

Maximum length is 256 characters.

$iconurl : string = ''

The URL to the icon.

$url : string = ''

The URL to the author.

Tags
throws
InvalidArgumentException
Return values
$this

setColor()

Sets the color of the embed.

public setColor(mixed $color) : $this
Parameters
$color : mixed
Return values
$this

setDescription()

Sets the description of the embed.

public setDescription(string $description) : $this
Parameters
$description : string
Return values
$this

setFooter()

Set the footer of this embed.

public setFooter(string $text[, string $iconurl = '' ]) : $this
Parameters
$text : string

Maximum length is 2048 characters.

$iconurl : string = ''

The URL to the icon.

Tags
throws
InvalidArgumentException
Return values
$this

setImage()

Set the image of this embed.

public setImage(string $url) : $this
Parameters
$url : string
Return values
$this

setThumbnail()

Set the thumbnail of this embed.

public setThumbnail(string $url) : $this
Parameters
$url : string
Return values
$this

setTimestamp()

Set the timestamp of this embed.

public setTimestamp([int|null $timestamp = null ]) : $this
Parameters
$timestamp : int|null = null
Tags
throws
Exception
Return values
$this

setTitle()

Sets the title of the embed.

public setTitle(string $title) : $this
Parameters
$title : string
Return values
$this

setType()

Sets the type of the embed.

public setType(string $type) : $this
Parameters
$type : string
Return values
$this

setURL()

Set the URL of this embed.

public setURL(string $url) : $this
Parameters
$url : string
Return values
$this

unserialize()

Unserializes some data and stores it. Used for Serializable.

public unserialize(string $data) : mixed
Parameters
$data : string

Some serialized data.

Tags
see
self::setAttribute()

The unserialized data is stored with setAttribute.

Return values
mixed

afterConstruct()

Called after the part has been constructed.

protected afterConstruct() : void
Return values
void

exceedsOverallLimit()

Checks to see if adding a property has put us over Discord's 6000-char overall limit.

protected exceedsOverallLimit(int $addition) : bool
Parameters
$addition : int
Return values
bool

getAuthorAttribute()

Gets the author attribute.

protected getAuthorAttribute() : Author
Return values
Author

The author attribute.

getFooterAttribute()

Gets the footer attribute.

protected getFooterAttribute() : Footer
Return values
Footer

The footer attribute.

getImageAttribute()

Gets the image attribute.

protected getImageAttribute() : Image
Return values
Image

The image attribute.

getThumbnailAttribute()

Gets the thumbnail attribute.

protected getThumbnailAttribute() : Image
Return values
Image

The thumbnail attribute.

getTimestampAttribute()

Gets the timestamp attribute.

protected getTimestampAttribute() : Carbon
Return values
Carbon

The timestamp attribute.

getVideoAttribute()

Gets the video attribute.

protected getVideoAttribute() : Video
Return values
Video

The video attribute.

resolveColor()

Resolves a color to an integer.

protected static resolveColor(array<string|int, mixed>|int|string $color) : int
Parameters
$color : array<string|int, mixed>|int|string
Tags
throws
InvalidArgumentException
Return values
int

setColorAttribute()

Sest the color of this embed.

protected setColorAttribute(mixed $color) : mixed
Parameters
$color : mixed
Tags
throws
InvalidArgumentException
Return values
mixed

setDescriptionAttribute()

Sets the description of this embed.

protected setDescriptionAttribute(string $description) : mixed
Parameters
$description : string

Maximum length is 2048 characters.

Tags
throws
InvalidArgumentException
Return values
mixed

setFieldsAttribute()

Sets the fields attribute.

protected setFieldsAttribute(array<string|int, Field$fields) : mixed
Parameters
$fields : array<string|int, Field>
Return values
mixed

setTitleAttribute()

Set the title of this embed.

protected setTitleAttribute(string $title) : $this
Parameters
$title : string

Maximum length is 256 characters.

Tags
throws
InvalidArgumentException
Return values
$this

setTypeAttribute()

Sets the type of the embed.

protected setTypeAttribute(string $type) : mixed
Parameters
$type : string
Tags
throws
InvalidArgumentException
Return values
mixed

attributeHelper()

Helps with getting embed attributes.

private attributeHelper(string $key, string $class) : mixed
Parameters
$key : string

The attribute key.

$class : string

The attribute class.

Tags
throws
Exception
Return values
mixed

checkForMutator()

Checks if there is a mutator present.

private checkForMutator(string $key, string $type) : string|false
Parameters
$key : string

The attribute name to check.

$type : string

Either get or set.

Return values
string|false

Either a string if it is callable or false.

getAttribute()

Gets an attribute on the part.

private getAttribute(string $key) : mixed
Parameters
$key : string

The key to the attribute.

Tags
throws
Exception
Return values
mixed

Either the attribute if it exists or void.

getEmbedTypes()

Returns all possible embed types.

private static getEmbedTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

setAttribute()

Sets an attribute on the part.

private setAttribute(string $key, mixed $value) : void
Parameters
$key : string

The key to the attribute.

$value : mixed

The value of the attribute.

Return values
void

Search results