Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

node.js - Emoji must be a string or Emoji/ReactionEmoji from getting a custom emote

I'm trying to make my Bot react with a custom emote to every message a specific user sends.
My code currently is :

if (msg.content.startsWith("")) {
            msg.react(msg.guild.emojis.get("475766563719479296"))
        }

Even though I checked everything, I still get this error :

(node:13640) UnhandledPromiseRejectionWarning: TypeError: Emoji must be a string or Emoji/ReactionEmoji
at Message.react (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_modulesdiscord.jssrcstructuresMessage.js:437:23)
at Client.client.on (C:UsersLarsDocumentsBotsSupport Bot [Resanance]index.js:40:17)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_modulesdiscord.jssrcclientwebsocketpacketshandlersMessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_modulesdiscord.jssrcclientwebsocketpacketsWebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:296:17)
at WebSocket.onMessage (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_moduleswslibevent-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:UsersLarsDocumentsBotsSupport Bot [Resanance]
ode_moduleswslibwebsocket.js:137:47)

I don't know what could be wrong. Could someone help me?

Edit: I did try msg.react("475766563719479296") but it's just the Error unknown emoji.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try using this instead:

const like = client.emojis.find(emoji => emoji.name === "like");

const dislike = client.emojis.find(emoji => emoji.name === "dislike");

message.react(like);

message.react(dislike);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...