用户登录
用户注册

分享至

我将如何对 [discord.js] 中的特定消息做出反应

  • 作者: 听说段子很搞笑
  • 来源: 51数据库
  • 2022-10-21

问题描述

我正在尝试让我的机器人对频道中的特定消息做出反应.这是我到目前为止的代码:

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");
    }
}
软件
前端设计
程序设计
Java相关