'How to send reactions and also awaitReactions on the same message
Ok, so a little bit of background, I am very new to Javascript and am making a discord bot to play simple text based games, currently I am recreating TicTacToe, I have the game fully working with commands but want to utilize discord reactions as it is generally easier for a user to just click the corresponding button than to type out an entire command.
Here I am trying to prompt the user to pick either Xs or Os, I have been able to react to my own message with with the proper emojis ❎ and 🅾️, but I am having trouble implementing the awaitReactions function.
module.exports = function (message, args){
breakme: if(boardSet == false){
let emb = embedMake ("Board Set:", displayBoard.join("") + "\nSince this is a two player game, someone needs to be Xs and someone needs to be Os? (react with ❎ to be X or 🅾️ to be O)" )
message.channel.send({embeds: [emb]})
.then(sentEmbed => {
sentEmbed.react("❎")
sentEmbed.react("🅾️")
})
.awaitReactions({max: 2, time: 60000, errors: ['time'] })
.then(collected => {
if (collected.emoji.name === '❎') {
message.channel.send('You reacted with a ❎');
} else if(collected.emoji.name === '🅾️'){
message.channel.send('You reacted with a 🅾️');
}else{
message.channel.send("You didn't react with ❎ or 🅾️");
}
})
boardSet = true;
}
}
From what I've seen, people set it up by doing message.awaitReactions, but if I were to do it in that fashion, I would only be awaiting reactions on the original command that starts the game to begin with, when I want to be awaiting reactions from my response to that command.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
