gpt4 book ai didi

node.js - 添加特定 unicode 表情时 Discord.js message.react 失败

转载 作者:太空宇宙 更新时间:2023-11-03 21:49:04 26 4
gpt4 key购买 nike

昨天我开始使用discord.js 的指南编写一个机器人。 The core与您完成命令处理程序部分的内容相同。
我当时正在开发一个投票命令,机器人会使用 Unicode 符号使用react,例如 :one: :two: :third:。
这就是我遇到问题的地方。使用:

module.exports = {
name: 'testing',
description: 'creates a reaction',
aliases: ['test'],
cooldown: 1,
execute(message, args) {
if (!args.length) {
message.react(':one:');
}
}

};给我一个 DiscordAPIError: Unknown Emoji

我花了一些时间尝试不同的表情,例如 🔥,它们按预期工作。使用表情 ID (422515569623957504) 对我来说效果不佳。

这是我这边的错误还是bug?

最佳答案

在 Discord.js 中,要使用表情符号响应消息,您需要编写表情符号(使用 🔥 或 😀,完整列表 here )或使用 Emoji 。要对数字使用react,您可以使用以下命令:

0⃣ 1⃣ 2⃣ 3⃣ 4⃣ 5⃣ 6⃣ 7⃣ 8⃣ 9⃣ 🔟

Just copy the number you need and you're all set.
To react a message with a custom emoji, you need to do something like this:

message.react(message.guild.emojis.get('123456789012345678'))
.then(console.log)
.catch(console.error);

注意:机器人可以使用所有服务器(例如 Nitro)中的表情符号。 client.emojis 返回机器人可以使用的所有表情符号的集合,client.emojis.get('id') 从另一台服务器获取表情符号。

关于node.js - 添加特定 unicode 表情时 Discord.js message.react 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49225971/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com