问题
Yesterday I started coding a bot using the guide from discord.js. The core is just with what you finish the Command Handler part with.
I was working on a voting command, where the bot would react with Unicode symbols like :one: :two: :three:.
This is where I encounter my problem. Using:
module.exports = {
name: 'testing',
description: 'creates a reaction',
aliases: ['test'],
cooldown: 1,
execute(message, args) {
if (!args.length) {
message.react(':one:');
}
}
};
Gives me a DiscordAPIError: Unknown Emoji
I spend some time trying different emotes like 🔥 and they are working as expected. Using the emote ID (422515569623957504) does not work as well for me.
Is this a mistake on my side or a bug?
回答1:
In Discord.js to react a message with a emoji you need to write the emoji (with 🔥 or 😀, full list here) or with a Emoji. To react with numbers you can use this:
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 message, you need to do something like this:
message.react(message.guild.emojis.get('123456789012345678'))
.then(console.log)
.catch(console.error);
Note: Bots can use emojis from all servers (like Nitro). client.emojis
returns a Collection of all emojis the bot can use, client.emojis.get('id')
to get the emoji from another server.
来源:https://stackoverflow.com/questions/49225971/discord-js-message-react-fails-when-adding-specific-unicode-emotes