Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript type for Emoji.id is wrong, or there's a bug somewhere else #9948

Closed
jeremy-rifkin opened this issue Nov 12, 2023 · 2 comments · Fixed by #9953
Closed

Typescript type for Emoji.id is wrong, or there's a bug somewhere else #9948

jeremy-rifkin opened this issue Nov 12, 2023 · 2 comments · Fixed by #9953

Comments

@jeremy-rifkin
Copy link
Contributor

jeremy-rifkin commented Nov 12, 2023

Which package is this bug report for?

discord.js

Issue description

I have had a very difficult time reproducing this bug.

Background: I have observed buggy behavior in a starboard component in my bot. Messages can get stuck in a state where the the bot doesn't put them on the starboard despite setting the right reaction counts. Rebooting the bot allows the messages to get onto the starboard.

In order to reproduce I have to leave my bot running for hours while people react to messages.

Through triage I have found that the error is I'm relying on a check reaction.emoji.id === null, but somehow reaction.emoji.id is undefined instead of null.

What I observe when printing Discord.MessageReaction objects to the console is the following:
Sometime for a ⭐ reaction the emoji looks like the following

  _emoji: ReactionEmoji {
    animated: null,
    name: '⭐',
    id: null,
    reaction: [Circular *2]
  },

Other times I see the following:

  _emoji: ReactionEmoji {
    animated: false,
    name: '⭐',
    id: undefined,
    reaction: [Circular *2]
  },

This is the _emoji field of Discord.MessageReaction, but based on https://github.com/discordjs/discord.js/blob/dbb92e5bc416d4fc3cbe7197baa941a1583d95b5/packages/discord.js/src/structures/MessageReaction.js#L81C1-L93C4 it should match.

Code sample

// The code looks something like this
    meets_threshold(reaction: Discord.MessageReaction) {
        assert(reaction.emoji.name);
        if (!(reaction.emoji instanceof Discord.GuildEmoji || reaction.emoji.id === null)) {
            return false;
        }
        // ...

Versions

  • discord.js 14.13.0
  • node v18.18.0
  • typescript 4.9.3
  • Ubuntu 20.04

Note: I have had issues with odd behavior with message reactions going back to 14.8. At that point the reaction counts were buggy.

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

User, Channel, Message, Reaction

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildModeration, GuildEmojisAndStickers, GuildIntegrations, GuildWebhooks, GuildInvites, GuildVoiceStates, GuildMessages, GuildMessageReactions, GuildMessageTyping, DirectMessages, DirectMessageReactions, DirectMessageTyping, MessageContent

I have tested this issue on a development release

No response

@jeremy-rifkin
Copy link
Contributor Author

One additional detail I can add: I've only observed this happening with ⭐ reactions, which the bot adds automatically as soon as a message with an image/video is sent in the server's #memes channel. Other reactions that users add seem unaffected.

@jeremy-rifkin
Copy link
Contributor Author

Thanks for the quick sole @almeidx!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants