简体   繁体   English

通过 ID discord.js 添加对消息的反应

[英]Add reaction to a message by ID discord.js

I would like to add a reaction to a message by message ID.我想通过消息 ID 添加对消息的反应。 For example, messageID.react('') .例如, messageID.react('') Is there a way to do that?有没有办法做到这一点?

messages.fetch() returns a promise. messages.fetch()返回一个 promise。 So in order to react to the message fetched, you can do it in two ways.因此,为了对获取的消息做出反应,您可以通过两种方式进行。

Using .then() :使用.then()

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

Using await :使用await

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

You need to have the text channel the message is sent in, then you can just do:您需要有发送消息的文本通道,然后您可以这样做:

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

Found the answere:找到了答案:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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