Reputation: 6710
I am trying to have an embed get deleted once a user reacts 🚮
//msg = embed
message.channel.send(msg).then(msg => {
msg.react('👍')
msg.react('👎')
msg.react('🚮')
const trashFilter = reaction => {
return ['🚮'].includes(reaction.emoji.name)
}
msg.awaitReactions(trashFilter, { max: 1, time: 2592000, errors: ['time'] }).then((collected, msg) => {
const reaction = collected
if (reaction === '🚮') {
msg.delete({ timeout: 100 })
}
})
})
This does not successfully delete the message. Any better methods to do this?
Upvotes: 1
Views: 83
Reputation: 5174
Your issue is caused by the msg
parameter you passed within awaitReactions()
's then()
since msg.delete()
does not refer to the original msg
and also awaitReactions()
does not return a message, just a collection of messageReactions
so you only need to pass collected
message.channel.send(msg).then(msg => {
msg.react('👍')
msg.react('👎')
msg.react('🚮')
const trashFilter = reaction => {
return ['🚮'].includes(reaction.emoji.name)
}
msg.awaitReactions(trashFilter, { max: 1, time: 2592000, errors: ['time'] }).then((collected) => {
const reaction = collected
if (reaction === '🚮') {
msg.delete({ timeout: 100 })
}
})
})
Upvotes: 1