ReactionGroup
Class · Sharkord\Collections\Groups\ReactionGroup
Class ReactionGroup
Represents all reactions of a single emoji type on a message.
Instances are returned from the Reactions collection when accessing reactions by emoji name (e.g. $message->reactions[‘olive’]).
Examples
Section titled “Examples”$group = $message->reactions['olive'];
echo $group->emoji; // "olive"echo $group->count; // 2
foreach ($group->users as $user) { echo $user->name;}
// Check whether a specific user has reactedif ($group->hasUser($sharkord->bot->id)) { echo "Bot has already reacted with :olive:";}Methods
Section titled “Methods”__construct()
Section titled “__construct()”ReactionGroup constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
$emoji | string | The emoji shortcode name this group represents (e.g. “olive”). |
$reactions | array | The raw reaction entries from the API for this emoji. |
getUsers()
Section titled “getUsers()”Returns all resolved User objects who placed this reaction.
Users that cannot be resolved from the cache (e.g. they left the server before the reaction event arrived) are silently omitted.
Returns \User[]
getCount()
Section titled “getCount()”Returns the number of users who placed this reaction.
Returns int
hasUser()
Section titled “hasUser()”Determines whether a specific user has placed this reaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
$userId | `int | string` |
Returns bool
toArray()
Section titled “toArray()”Returns all raw reaction entries for this emoji group. Useful for debugging.
Returns array
__get()
Section titled “__get()”Magic getter. Provides shorthand property-style access to common values.
Supported virtual properties:
- $group->users → User[] (calls getUsers())
- $group->count → int (calls getCount())
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns mixed
__isset()
Section titled “__isset()”Magic isset check.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns bool