Mr Brickstar
Mr Brickstar

Reputation: 308

Add reaction to a message by ID discord.js

I would like to add a reaction to a message by message ID. For example, messageID.react('👍'). Is there a way to do that?

Upvotes: 0

Views: 6639

Answers (3)

Spimy
Spimy

Reputation: 340

messages.fetch() returns a promise. So in order to react to the message fetched, you can do it in two ways.

Using .then():

channel.messages.fetch(msg).then(m => {
    m.react("👍");
});

Using await:

const m = await channel.messages.fetch(msg);
m.react("👍");

Upvotes: 4

Mr Brickstar
Mr Brickstar

Reputation: 308

Found the answere:

channelID.messages.fetch(MESSAGE_ID).then(function (message) { message.react("👍") })

Upvotes: 1

Aplet123
Aplet123

Reputation: 35512

You need to have the text channel the message is sent in, then you can just do:

channel.messages.fetch(messageId).react("👍");

Upvotes: 2

Related Questions