'Why awaitReactions not working? | discord.js v13
I was trying to make a marriage system, but the thing is that reaction collector isn't working at all even the both parties reacted to the emoji. There's no error at all. After executing the command, it will only showing the embed but not totally collecting the reactions and sending the reply content
const filter = (reaction, user) => {
return (reaction.emoji.name === "👍" || reaction.emoji.name === "👎") && user.id == member.id;
}
return message.awaitReactions({filter, max: 1, time: 10000, errors: ['time']})
.then(collected => {
const reaction = collected.first();
if(reaction.emoji.name === "👎") {
return message.channel.send("I think **no**...");
}
if(reaction.emoji.name === "👍") {
marriage.findOne({
guildID: message.guild.id
},async (err, data) => {
if(data) {
data.memberID
data.userID
await data.save()
} else {
new marriage({
guildID: message.guild.id,
userID: user.id,
memberID: member.id
}).save()
return message.channel.send(`${user.username} and ${member.user.username} are now married!`)
}
})
}
})
.catch(() => {
message.reply("No reaction after 10 seconds, operation canceled.")
})
EDIT:
if(exist != user.id && exist != member.id) {
const proposal = new MessageEmbed()
.setTitle("IMPORTANT ANNOUNCEMENT!!")
.setDescription(`${user.username} makes a marriage proposal to ${member.user.username}.\nAre you ready to get married?`)
.setColor('RANDOM')
.setTimestamp()
message.channel.send({embeds: [proposal]})
.then((message) => {
message.react("❤️")
message.react("💔")
This is the part of the message for collection
Solution 1:[1]
If the filter and awaitReactions are not inside of the .then((message) =>) its not going to work, first you need to put it inside
message.channel.send({embeds: [proposal]})
.then((message) => {
message.react("??")
message.react("?")
const filter = (reaction, user) => {
return (reaction.emoji.name == "??" || reaction.emoji.name == "?")
&& user.id == member.id
}
return message.awaitReactions({ filter, max: 1, time: ms('10s'), errors:["time "]})
second the emojis are different in your embed and filter you should change it too.
message.channel.send({embeds: [proposal]})
.then((message) => {
message.react("??")
message.react("?")
const filter = (reaction, user) => {
return (reaction.emoji.name == "??" || reaction.emoji.name == "?")
&& user.id == member.id
}
return message.awaitReactions({ filter, max: 1, time: ms('10s'), errors:["time "]})
}).then((collected) =>
//your codes here
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | æ–°Acesyyy |
