#fetch embeds from MessageReactionAdd?

14 messages · Page 1 of 1 (latest)

static glade
#

With my bot, I have it send an image every 3 minutes from an API. What I would like to do is then send the image to a user that reacts to the embed with a ✅. As it stands, reaction.message.embeds[0] always shows up as empty, despite the message being reacted to clearly having embeds.

client.on('messageReactionAdd', async (reaction, user) => {
    if (reaction.emoji.name == '❌' && !user.bot) {
        user.id == reaction.message.interaction.user.id ? reaction.message.delete() : user.send('You can only delete your own requests!')
    }
    // if the interaction is reacted to with a checkmark, send a message to the user
    if (reaction.emoji.name == '✅' && !user.bot) {
        console.log(reaction.message.embeds[0])
        user.send(`Lorem Ipsum and all that jazz`)
    }
})
#

The user.send is just so I know the bot is actually trying to do something.

cerulean brook
#

Try

const message = await reaction.message.fetch();
console.log(message.embeds[0])
static glade
#

Yep, that did the trick! I keep forgetting Node is asynchronous. Thanks a tonne!

wicked sapphire
#

well

#

that's not quite the issue here

static glade
#

I wasn't waiting for the message to be cached so that it could properly utilize it?

wicked sapphire
#

you aren't "waiting" for anything

#

you are fetching the message

#

since i assume that you have reaction and message partials enabled

#

in which case, when discord sends the event, you only have the message id, as that's only thing they send

static glade
#

That makes sense

wicked sapphire
#

that's why you have to specifically fetch the message the first time (as it's partial message)

static glade
#

Yeah, that makes a lot more sense than my sleep deprived explanation. Thanks for the elaboration XD