Skip to content

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’]).

$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 reacted
if ($group->hasUser($sharkord->bot->id)) {
echo "Bot has already reacted with :olive:";
}

ReactionGroup constructor.

Parameters

ParameterTypeDescription
$sharkordSharkordReference to the main bot instance.
$emojistringThe emoji shortcode name this group represents (e.g. “olive”).
$reactionsarrayThe raw reaction entries from the API for this emoji.

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[]


Returns the number of users who placed this reaction.

Returns int


Determines whether a specific user has placed this reaction.

Parameters

ParameterTypeDescription
$userId`intstring`

Returns bool


Returns all raw reaction entries for this emoji group. Useful for debugging.

Returns array


Magic getter. Provides shorthand property-style access to common values.

Supported virtual properties:

  • $group->users → User[] (calls getUsers())
  • $group->count → int (calls getCount())

Parameters

ParameterTypeDescription
$namestringProperty name.

Returns mixed


Magic isset check.

Parameters

ParameterTypeDescription
$namestringProperty name.

Returns bool