DiscordJS - React with a :one:

Viewed 907

I cannot figure out how to react with a :one: Emoji with DiscordJs.

Usually placing an escape \ infront of the Emoji would give you the id of the Emoji, but with \ this happens

Reacting with :one: or one or the discord link doesn't work either.

(https://ptb.discordapp.com/assets/d10eead5823437c08b5287cf93bd5223.svg => 10eead5823437c08b5287cf93bd5223)

When using the symbol that @Nathn suggested, it still throws an error: enter image description here

My Solution

The solution that I used was to pick "E0.6 keycap 1" from an Emoji Picker instead of "keycap 1". I recommend doing it the way @a2br suggested with creating your own emote - that way it will stay consistent across devices.

Also if you are going to put those emojis into fixed width text containers you wont need to worry about the "keycap 1" actually being 3 characters (1 + glueChar + keyCap) and rendering it as 3 characters on some devices and other devices rendering it as 1.5 width for whatever reason.

2 Answers

It's been a long time since I last used Discord.js, but I remember very well this specific issue; I don't know why, but Discord bots do not support the number emojis.

I think you could avoid that problem by creating a custom emoji in a server your bot is in (and using <:one:000000000000000000> with whatever your emoji ID is), the only difference is that it'll render the same on mobile platforms, where emojis should usually be rendered natively.

Edit: Oh, I didn't read the whole question. The solution above was written for text messages, not reactions. So, for reactions, it'd be message.react("000000000000000000"). There's probably a better solution though, also here is what's been answered in another SO question.

You can try Unicode short names like :one: or you can use the escaped versions/Unicode characters like 1️⃣ in the message.react().

Examples:

//Unicode shortnames
message.react(':one:')


//Unicode character
message.react('1️⃣')

Note that both the short name or Unicode characters need to be in a string.

Related