Node.js 表情符号必须是字符串或表情符号/ReactionMoji,才能获取自定义表情符号
我试图让我的机器人对特定用户发送的每一条消息都使用自定义表情进行反应。Node.js 表情符号必须是字符串或表情符号/ReactionMoji,才能获取自定义表情符号,node.js,discord,discord.js,Node.js,Discord,Discord.js,我试图让我的机器人对特定用户发送的每一条消息都使用自定义表情进行反应。 我目前的代码是: if (msg.content.startsWith("")) { msg.react(msg.guild.emojis.get("475766563719479296")) } 尽管我检查了所有内容,但仍然出现以下错误: (node:13640) UnhandledPromiseRejectionWarning: TypeError: Emoji must be
我目前的代码是:
if (msg.content.startsWith("")) {
msg.react(msg.guild.emojis.get("475766563719479296"))
}
尽管我检查了所有内容,但仍然出现以下错误:
(node:13640) UnhandledPromiseRejectionWarning: TypeError: Emoji must be a string or Emoji/ReactionEmoji
at Message.react (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\discord.js\src\structures\Message.js:437:23)
at Client.client.on (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\index.js:40:17)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:\Users\Lars\Documents\Bots\Support Bot [Resanance]\node_modules\ws\lib\websocket.js:137:47)
我不知道会出什么问题。
有人能帮我吗
编辑:
我确实尝试了
msg.react(“475766563719479296”)
,但这只是未知表情的错误。没关系,我复制了错误的ID尝试使用以下方法:
const like = client.emojis.find(emoji => emoji.name === "like");
const dislike = client.emojis.find(emoji => emoji.name === "dislike");
message.react(like);
message.react(dislike);
你能发布更多的上下文代码吗?你试过使用
msg.react(“475766563719479296”)
?