简体   繁体   English

为什么 .add_reaction 不适用于 unicode 表情符号?

[英]Why is .add_reaction not working with unicode emojis?

I canot seem to get this single line of code to output anything except BAD REQUEST Unknown Emoji除了BAD REQUEST Unknown Emoji之外,我似乎无法让这一行代码输出任何内容

await dBot.add_reaction(message,"\\U00000031")

I cannot find any reason online why this shouldnt work.我在网上找不到任何原因,为什么这不应该起作用。 What wonderful noob mistake am I making?我犯了什么奇妙的菜鸟错误?

The string you're using isn't an escaped Unicode character, but an escaped backslash character followed by eight digit characters.您使用的字符串不是转义的 Unicode 字符,而是后跟八个数字字符的转义反斜杠字符。 You probably want only one backslash in the literal, which will let Python parse the literal into a single character as it seems you intend.您可能只需要文字中的一个反斜杠,这样 Python 就可以按照您的意图将文字解析为单个字符。 I'm still not sure that will do what you expect though, since "\\U00000031" is the character '1' , not an emoji.我仍然不确定这会达到您的预期,因为"\\U00000031"是字符'1' ,而不是表情符号。

From your comment below, it sounds like the emoji you actually want is composed of two Unicode codepoints.从您下面的评论中,听起来您真正想要的表情符号是由两个 Unicode 代码点组成的。 The first is just the normal '1' character I discussed above, which you don't need any escapes to write.第一个只是我上面讨论的普通'1'字符,你不需要任何转义来编写。 The second character is U+20E3 ('COMBINING ENCLOSING KEYCAP'), which can be written in a Python literal as '\⃣' or '\\U000020E3' .第二个字符是U+20E3 ('COMBINING ENCLOSING KEYCAP'),它可以用 Python 文字写成'\⃣''\\U000020E3' This puts a keyboard key image around whatever the previous character was, so the sequence "1\⃣" will render as 1⃣ (which my browser doesn't handle too well, but yours might).这会在前一个字符周围放置一个键盘键图像,因此序列"1\⃣"将呈现为 1⃣(我的浏览器处理得不好,但你的可能)。 I don't know for sure, but I'd be fairly confident that discord would accept that, if it support the 1 key emoji you're looking for at all (which I expect it does).我不确定,但我相当有信心 discord 会接受这一点,如果它完全支持您正在寻找的1键表情符号(我希望它确实如此)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM