简体   繁体   中英

How would I react to a specific message in [discord.js]

I'm trying to make my bot react to a specific message in a channel. This is the code I have so far:

message.fetch(`messageID`).then(message => {
  message.react(`emoji`);
});

To fetch a specific message you must at least fetch it's channel before:

message.client.channels.fetch("channelID").then(channel => {
    channel.messages.fetch("messageID").then(message => {
        message.react("emoji");
    }
}
bot.on('message', message=>{
  message.bot.channels.fetch("channelID").then(channel => {
    channel.messages.fetch("messageID").then(message => {
        message.react(emoji);
    })
  })
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM