Discord.js 从 message.content 获取 Unicode 表情符号

Discord.js getting Unicode emojis from message.content

我目前正在尝试创建一个机器人,它对一条消息做出反应,该消息会使用发送它的消息中包含的任何表情符号对其进行发送(因此,例如 @Robot#1234 :robot: 会得到一个 :robot:反应)。我很容易弄清楚如何识别发送的表情符号,并且使用自定义表情做出反应也很容易(就像您可以做的那样 message.react("<:customRobot:12345>");)。但是,正如每个 google 列表都会告诉你的那样,如果你要使用它,你必须获得你想要与之反应的任何表情符号的实际 unicode 表示,所以你不能只做 message.react("<:robot:838287833931317288>");.

话虽这么说:有什么方法可以动态查找 unicode 表情符号的 <:name:id> 表示并将其转换为 unicode 表情符号的实际字符串形式? (:robot: 会是)

看起来 emoji-name-map 模块可能对这里有帮助:https://github.com/IonicaBizau/emoji-name-map。包括从字符串格式到字符本身的转换(即 unicode 表示),我认为您可以在 discord.js.

中使用 message.react

额外功能:还有一个模块 emoji-unicode (https://github.com/IonicaBizau/emoji-unicode) to get the raw unicode values from the character itself if you really need them, or there are some other stack overflow answers that explain how to do this manually if you'd rather avoid importing a library: see or .