I currently have a messageReactionAdd and after that it will DM an embed, that works but now i want to listen a reaction on that DM but it is just a message in a conversation so it doesnt need to listen in it. I can send a DM in my messageReactionAdd and it also reacts the correct items but when i react on the thumbs up, it wouldn't log the TEST as i did, here is my code:
member.send(currentEmbed).then((message) => {
//Iterate through the dividers
for(var j = 0; j < dividers.length; j++) {
//Create variable to dump current number in emoiji form
var number = "";
//Convert digit to emoji form
switch(dividers[j]) {
case 1:
number = "👍";
break;
case 2:
number = "2️⃣";
break;
case 3:
number = "3️⃣";
break;
case 4:
number = "4️⃣";
break;
default:
number = "";
break;
}
//React a message with the current digit in emoji form
message.react(number);
}
//Await the thumbsup reaction **DEBUGGING
message.awaitReactions(reaction => reaction.emoji.name === "👍", {time: 150000}).then(msg => {
console.log("TEST");
});
});
Don't mind the complex for loop, that is just for reacting al possible combinations and that works just fine.
The event messageReactionAdd works on the cached messages as they say in the documentation https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-messageReactionAdd
Emitted whenever a reaction is added to a cached message.
so what you can do is to cache your message when starting the bot in the ready event like so:
client.on('ready', ()=>{
client.channels.cache.get(CHANNEL_ID).messages.fetch(MESSAGE_ID);
});
Than the event messageReactionAdd would work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.