Reactions not working after restart

I began adding reaction roles onto my bot and it worked. However, the reaction events don’t seem to work after restarting the bot. After some research I managed to find out it has something to do with message caching but I’m not entirely sure what about it.

Here’s the reaction code:

client.on('messageReactionAdd', async (reaction, user) => {
  if (user.bot) return;
  if (reaction.message.partial) reaction.message.fetch()
  if (reaction.partial) reaction.fetch()
  if (reaction.emoji.id === '791026439452360714') {
    reaction.message.guild.members.cache.get(user.id).roles.add('799416358373949470')
    }
});

You should be using await when fetching the message & reaction.

client.on('messageReactionAdd', async (reaction, user) => {
  if (user.bot) return;
  if (reaction.message.partial) await reaction.message.fetch()
  if (reaction.partial) await reaction.fetch()
  if (reaction.emoji.id === '791026439452360714') {
    reaction.message.guild.members.cache.get(user.id).roles.add('799416358373949470')
    }
});
2 Likes

Yes, I did add await initially but it didn’t work.

You probably missed the async part at the top.