如何发送数字框表情符号(1️⃣)?
How do I send number boxes emojis (1️⃣)?
如何发送?如果我尝试这样做:msg.react('1️⃣') 它会回复一个错误,告诉我这是一个未知的表情符号。我该怎么办?
client.on("message", async msg => {
if (command === 'vote') {
msg.channel.send('response')
.then(m => m.react('1️⃣')
}
}
取自discordjs.guide ( the opensource guide maintained by the discord.js community).
做类似的事情(或只是复制并粘贴数字):
// 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: '', '#': '#⃣', '*': '*⃣',
'!': '❗', '?': '❓',
};
那么你可以这样做:
// index.js
const emojiCharacters = require('./emojiCharacters');
console.log(emojiCharacters.a); //
console.log(emojiCharacters[10]); //
console.log(emojiCharacters['!']); // ❗
你用了1️⃣而不是1⃣。是的,它们是不同的。
第一个有三个 unicode 代码点:
49 - 数字 1
65039 - "variation selector 16"¹
8419 - "combining enclosing keycap"(背景)
第二个版本中间没有那个代码点 (49, 8419),这似乎可行。
¹ 我发现 following quote 描述了它的含义:
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.
虽然 DiscordJS 不会忽略它,但这很有趣。
如何发送?如果我尝试这样做:msg.react('1️⃣') 它会回复一个错误,告诉我这是一个未知的表情符号。我该怎么办?
client.on("message", async msg => {
if (command === 'vote') {
msg.channel.send('response')
.then(m => m.react('1️⃣')
}
}
取自discordjs.guide ( the opensource guide maintained by the discord.js community).
做类似的事情(或只是复制并粘贴数字):
// 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: '', '#': '#⃣', '*': '*⃣', '!': '❗', '?': '❓', };
那么你可以这样做:
// index.js const emojiCharacters = require('./emojiCharacters'); console.log(emojiCharacters.a); // console.log(emojiCharacters[10]); // console.log(emojiCharacters['!']); // ❗
你用了1️⃣而不是1⃣。是的,它们是不同的。
第一个有三个 unicode 代码点:
49 - 数字 1
65039 - "variation selector 16"¹
8419 - "combining enclosing keycap"(背景)
第二个版本中间没有那个代码点 (49, 8419),这似乎可行。
¹ 我发现 following quote 描述了它的含义:
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.
虽然 DiscordJS 不会忽略它,但这很有趣。