Documentation

Reaction extends Part
in package

Represents a reaction to a message by members(s).

Table of Contents

$channel  : Channel|Thread
$channel_id  : string
$count  : int
$created  : bool
Is the part already created in the Discord servers?
$emoji  : Emoji
$guild  : Guild|null
$guild_id  : string|null
$id  : string
$me  : bool
$message  : Message|null
$message_id  : string
$scriptData  : mixed
Custom script data.
$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.
$visible  : array<string|int, mixed>
Attributes which are visible from debug info.
__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.
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.
getAllUsers()  : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Users[]>
Gets all the users that have used this reaction.
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.
getUsers()  : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Users[]>
Gets the users that have used the reaction.
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.
unserialize()  : mixed
Unserializes some data and stores it. Used for Serializable.
afterConstruct()  : void
Called after the part has been constructed.
getChannelAttribute()  : Channel|Thread
Gets the channel attribute.
getEmojiAttribute()  : Emoji
Gets the partial emoji attribute.
getGuildAttribute()  : Guild|null
Returns the guild that owns the channel the message was sent in.
getIdAttribute()  : string
Gets the emoji identifier, combination of `id` and `name`.
getMessageAttribute()  : Message|null
Gets the message attribute.
checkForMutator()  : string|false
Checks if there is a mutator present.
getAttribute()  : mixed
Gets an attribute on the part.
setAttribute()  : void
Sets an attribute on the part.

Properties

$channel

public Channel|Thread $channel

The channel that the message belongs tol

$channel_id

public string $channel_id

The channel ID that the message belongs in.

$count

public int $count

Number of reactions.

$created

Is the part already created in the Discord servers?

public bool $created = false

Whether the part has been created.

$guild

public Guild|null $guild

The guild that owns the channel the message belongs in.

$guild_id

public string|null $guild_id

The guild ID of the guild that owns the channel the message belongs in.

$id

public string $id

The identifier of the reaction.

$me

public bool $me

Whether the current bot has reacted.

$message_id

public string $message_id

The message ID the reaction is for.

$scriptData

Custom script data.

public mixed $scriptData

Used for storing custom information, used by end products.

$attributes

The parts attributes.

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

The parts attributes and content.

$discord

The Discord client.

protected Discord $discord

Client.

$fillable

The parts fillable attributes.

protected array<string|int, mixed> $fillable = ['count', 'me', 'emoji', 'message_id', 'channel_id', 'guild_id']

The array of attributes that can be mass-assigned.

Tags
inheritdoc

$fillAfterSave

Should we fill the part after saving?

protected bool $fillAfterSave = true

Whether the part will be saved after being filled.

$hidden

Attributes that are hidden from debug info.

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

Attributes that are hidden from public.

$http

The HTTP client.

protected Http $http

Client.

$regex

The regex pattern to replace variables with.

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

The regex which is used to replace placeholders.

$repositories

An array of repositories that can exist in a part.

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

Repositories.

$repositories_cache

An array of repositories.

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

$visible

Attributes which are visible from debug info.

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

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.

fetch()

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

public fetch() : ExtendedPromiseInterface<string|int, static>
Tags
inheritdoc
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

getAllUsers()

Gets all the users that have used this reaction.

public getAllUsers() : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Users[]>

Wrapper of the lower-level getUsers() function.

Return values
ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Users[]>

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>

getUsers()

Gets the users that have used the reaction.

public getUsers([array<string|int, mixed> $options = [] ]) : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Users[]>
Parameters
$options : array<string|int, mixed> = []

See https://discord.com/developers/docs/resources/channel#get-reactions

Return values
ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Users[]>

isPartial()

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

public isPartial() : bool
Tags
inheritdoc
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.

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

getChannelAttribute()

Gets the channel attribute.

protected getChannelAttribute() : Channel|Thread
Return values
Channel|Thread

getEmojiAttribute()

Gets the partial emoji attribute.

protected getEmojiAttribute() : Emoji
Tags
throws
Exception
Return values
Emoji

getGuildAttribute()

Returns the guild that owns the channel the message was sent in.

protected getGuildAttribute() : Guild|null
Return values
Guild|null

getIdAttribute()

Gets the emoji identifier, combination of `id` and `name`.

protected getIdAttribute() : string
Return values
string

getMessageAttribute()

Gets the message attribute.

protected getMessageAttribute() : Message|null
Return values
Message|null

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.

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