Discord.js: message.react does not correctly resolve custom emojis using identifier

Created on 29 Mar 2020  路  5Comments  路  Source: discordjs/discord.js

Update, not a bug - feature enhancement.

Assumed the below should have worked as expected, but is not the case - my bad.

Please describe the problem you are having in as much detail as possible:

For my use case, I'm retrieving an emoji identifier via client.emojis.resolveIdentifier using <:name:id>. Passing the resolved identifier value to message.react throws the following API error:

Also occurs if you first resolve the GuildEmoji from guild.emojis.resolve and pass the object to client.emojis.resolveIdentifier.

DiscordAPIError: Invalid Form Body
emoji_id: Value "693728847857713192>" is not snowflake.

Include a reproducible code sample here, if possible:

should be able to reproduce this by having the following code in your message listener, replacing custom_emoji with a valid custom emoji <:name:id>. I just typed this out here for minimal example.

const emojiIdentifier = message.client.emojis.resolveIdentifier(custom_emoji);
if (emojiIdentifier) message.react(emojiIdentifier);

Further details:

  • discord.js version: 12.1.1
  • Node.js version: 13.5.0
  • Operating system: Windows and OSX
  • Priority:
    Low , shouldn't be too difficult to fix and it impacts a pretty common / straight forward feature. (I'd pick it up myself, but I don't have the time right now, unfortunately)
  • [x ] I have also tested the issue on latest master, commit hash: 6544d2233804f01b08d15a88edf9b5331949353d
REST utility enhancement

Most helpful comment

After looking into this a bit:
This is not a bug, but a request for feature enhancement.

The documentation at GuildEmojiManager#resolveIdentifier asks for the EmojiIdentifierResolvable type, which is

  • The unicode representation of an emoji
  • An EmojiResolvable

The latteris defined as

  • A custom emoji ID
  • A GuildEmoji object
  • A ReactionEmoji object

Nowhere in the documentation does it imply that <a:name:id> or <:name:id> emoji literals are supported input.


However since the library does offer Util#parseEmoji - which does properly resolve said input - i'm sure this could be supported (although i'm not yet quite sure at which point of the parsing process that happens from the Message#react call)

All 5 comments

I was unable to reproduce this error with the given sample. For me it reacts just fine.

  const identifier = client.emojis.resolveIdentifier('692154789584175114');

  if (identifier) message.react(identifier);

image


Maybe I'm not doing something correctly, but I don't see any issue with this. Please do notify me if there's something that I missed.

Tested this on Discord.js v12.1.1 & Node.js v13.12.0

@SketchyLxve This is not the error case detailed in the issue, this is about providing the custom emoji as string with its full emoji literal <:name:id>

Ah I see, my bad, I misunderstood.

Ah I see, my bad, I misunderstood.

Not at all! My bad, I should have been more specific, I'll make an edit! I rushed the post, it certainly sounds like I meant resolving the identifier via anything.

After looking into this a bit:
This is not a bug, but a request for feature enhancement.

The documentation at GuildEmojiManager#resolveIdentifier asks for the EmojiIdentifierResolvable type, which is

  • The unicode representation of an emoji
  • An EmojiResolvable

The latteris defined as

  • A custom emoji ID
  • A GuildEmoji object
  • A ReactionEmoji object

Nowhere in the documentation does it imply that <a:name:id> or <:name:id> emoji literals are supported input.


However since the library does offer Util#parseEmoji - which does properly resolve said input - i'm sure this could be supported (although i'm not yet quite sure at which point of the parsing process that happens from the Message#react call)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PassTheMayo picture PassTheMayo  路  3Comments

Blumlaut picture Blumlaut  路  3Comments

smchase picture smchase  路  3Comments

Alipoodle picture Alipoodle  路  3Comments

kvn1351 picture kvn1351  路  3Comments