On Reaction Added Message
On Reaction Added Message blocks are event blocks that fire whenever a specific Discord message is reacted to with a specific emoji. Examples of their use cases are emoji-based voting, where members of the Discord server vote by reacting to a message with different emojis, and emoji-based captcha, where users are granted a "member" role that gives them access to the rest of the server only if they react to a message with a specific emoji, according to instructions.
On Reaction Added Message blocks require a Discord connection from a
Discord Connector block as an input (like all Discord-related blocks), as well as a Discord channel ID, a Discord message ID, and a string parameter called "EmoteName".
The message ID parameter informs the block of which Discord message to listen to for reactions, and the channel ID parameter informs the block of which channel the message is in.
The "EmoteName" parameter should be passed a string block containing the actual emoji that we are listening for with our
On Reaction Added Message block. If this particular emoji is used as a reaction on the message identified by the message ID parameter, then our
On Reaction Added Message block will fire.
On Reaction Added Message blocks also output a piece of data called "UserId", which is an identifier for the user who made the emoji reaction. This can be used for other blocks that require a Discord user ID as input, like the
Add Role User block in the example below.
In the following example, we use an
On Reaction Added Message block to help us build a simple captcha tool. The Discord channel in this example would be a sort of captcha waiting room which new server members would need to get past in order to acces the rest of the server.
After establishing a Discord connection through our bot using a
Discord Connector block (which will fire automatically when the graph begins), we output a message with our bot, instructing new users to react to that message with a brain emoji.
We then listen for emoji reactions on the message our bot just sent (note the "MessageID" input parameter on the
On Reaction Added Message block being supplied by the "MessageID" output of the
Send Discord Channel Message block). We use a
String block containing an actual brain emoji to inform the
On Reaction Added Message block of what emoji reaction type we are listening for.
If we do detect a brain emoji reaction, then we add a Discord role called "member" to the user who made the reaction (note the connection between the "UserId" output of the
On Reaction Added Message block and "UserId" input of the
Add Role User block). Presumably, a role called "member", which allows general access to the server, has been defined by an administrator of the Discord server. Thus, by reacting to the bot's message with a brain emoji as instructed, a user can prove they are human, and gain access to the server.