问题
How do I send them? If I try this: msg.react('1️⃣') it replies with an error telling me that this is an unknown emoji. What shall I do?
client.on("message", async msg => {
if (command === 'vote') {
msg.channel.send('response')
.then(m => m.react('1️⃣')
}
}
回答1:
Taken from discordjs.guide ( the opensource guide maintained by the discord.js community).
Do something like ( or just copy and paste the numbers ):
// emojiCharacters.js module.exports = { a: '🇦', b: '🇧', c: '🇨', d: '🇩', e: '🇪', f: '🇫', g: '🇬', h: '🇭', i: '🇮', j: '🇯', k: '🇰', l: '🇱', m: '🇲', n: '🇳', o: '🇴', p: '🇵', q: '🇶', r: '🇷', s: '🇸', t: '🇹', u: '🇺', v: '🇻', w: '🇼', x: '🇽', y: '🇾', z: '🇿', 0: '0⃣', 1: '1⃣', 2: '2⃣', 3: '3⃣', 4: '4⃣', 5: '5⃣', 6: '6⃣', 7: '7⃣', 8: '8⃣', 9: '9⃣', 10: '🔟', '#': '#⃣', '*': '*⃣', '!': '❗', '?': '❓', };
Then you could do:
// index.js const emojiCharacters = require('./emojiCharacters'); console.log(emojiCharacters.a); // 🇦 console.log(emojiCharacters[10]); // 🔟 console.log(emojiCharacters['!']); // ❗
回答2:
You used 1️⃣ instead of 1⃣. Yes, they are different.
The first one has three unicode codepoints:
49 - number 1
65039 - "variation selector 16"¹
8419 - "combining enclosing keycap" (the background)
The second version doesn't have that code point in the middle (49, 8419) and that seems to work.
¹ I found the following quote describing its meaning:
An invisible codepoint which specifies that the preceding character should be displayed with emoji presentation. Only required if the preceding character defaults to text presentation.
It's fun though that DiscordJS doesn't ignore it.
来源:https://stackoverflow.com/questions/57339653/how-do-i-send-number-boxes-emojis-1%ef%b8%8f%e2%83%a3