Moderation
getReactions
$getReactions
The function $getReactions[] retrieves the users who reacted to a message with a specific emoji.
Syntax
$getReactions[channelID;messageID;separator;emoji]
Parameters
| Parameter | Description |
|---|---|
channelID |
The ID of the channel containing the message. Required. |
messageID |
The ID of the target message. Required. |
separator |
The text inserted between each user name. Required (may be empty). |
emoji |
The emoji to read. Unicode (👍), custom (<:name:ID> or <a:name:ID>), the ID of a custom emoji, or a :name: alias known to the engine. Required. |
Return Value
- Type: String
- The names of the users who reacted with this emoji, joined with the separator (all pages of reactions are read).
- The user name, followed by
#discriminatoronly for accounts that still have one. - An empty string if nobody reacted with this emoji.
- An error is raised if an ID is invalid, if the emoji is empty or invalid, or if the message cannot be read.
Behavior
- Returns the users, not a count.
- Each user appears once.
- The channel must be a message channel (
Reactions require a message channel.) and the message must exist; a custom emoji given by ID must be known to the bot (Custom emoji is unavailable to the bot.).
Examples
Poll results
$title[Results of the poll]
$description[
**Yes:** $getReactions[$channelID;$messageID;, ;👍]
**No:** $getReactions[$channelID;$messageID;, ;👎]
]
$color[#5865F2]
Nobody has validated
$if[$getReactions[$channelID;$messageID;,;✅]==]
$sendMessage[Nobody has reacted with ✅ yet.]
$else
$sendMessage[Validated by: $getReactions[$channelID;$messageID;, ;✅]]
$endif
Giveaway
$sendMessage[Participants: $getReactions[$channelID;$messageID;, ;🎉]]
Notes
- To test whether one given user reacted, use
$userReacted[channelID;messageID;userID;emoji]. - To count the reactions, split the result with
$textSplit[]and read$getTextSplitLength(an empty result still gives one empty element).
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.