N
N
nikkkushkaaa2021-11-05 00:25:44
Node.js
nikkkushkaaa, 2021-11-05 00:25:44

How to read reaction to old discord message?

Hello, I'm interested in the question of how to read the setting of the reaction to the old message? That is, if the user put a certain reaction in the messages "32135456546", then the bot reacts to it.
My bot reacts perfectly to new messages with a reaction, but after restarting the bot does not see the old messages and new reactions to them

robot.on('messageReactionAdd', async (reaction, user) => {
  if (reaction.message.partial) await reaction.message.fetch();
  if (reaction.partial) await reaction.fetch();
  if (user.bot) return;
  if (!reaction.message.guild) return;
  console.log(`${user.tag} поставил реакцию ${reaction.emoji.name} на сообщении ${reaction.message.id}.`);
  if (client.channels.cache.get === "905864030718156882") {
  }
  });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seira-code, 2021-11-06
@seira-code

Hey, you need to fetch these messages.
If these are specific messages, let's say getting roles by reaction, then you can do this:

robot.channels.cache.get('айди канала').messages.fetch('айди сообщения')

If these are messages from other users, then here you can try to do this
robot.channels.cache.forEach((channel)=>{
channel.messages.fetch({ limit: 1000 })
})

But the discord can impose a rate limit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question