0

I have written a command with which the bot should react to another message. The command is reacted to, the code is correct as far as it goes, but this is what comes from the bot:

TypeError: msg.react is not a function

Is this not possible from the API, or is the code wrong?

Code:

    if (message.member.hasPermission('MANAGE_CHANNELS')) {
        const args = message.content.slice(prefix.length).trim().split(' ');
        const messages = args[1]
        const emoji = args[2]

        const msg = message.channel.messages.fetch(messages)
        msg.react(emoji)
    }
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57
Mortix
  • 1
  • Does this answer your question? [Is there a way to react to every message ever sent with discord.js](https://stackoverflow.com/questions/56937895/is-there-a-way-to-react-to-every-message-ever-sent-with-discord-js) – miquelvir Mar 27 '21 at 22:17
  • Does this answer your question? [How would I react to a specific message in discord.js](https://stackoverflow.com/questions/61920693/how-would-i-react-to-a-specific-message-in-discord-js) – miquelvir Mar 27 '21 at 22:19

1 Answers1

0

messages.fetch() returns a promise so you need to resolve it first:

message.channel.messages.fetch(messages)
  .then(msg => msg.react(emoji))

Or you can use await:

const msg = await message.channel.messages.fetch(messages)
msg.react(emoji)
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57