Skip to content

Conversation

@Jiralite
Copy link
Member

Please describe the changes this PR makes and why it should be merged:

When receiving a non-burst reaction over the gateway, we get this (example) payload:

{
  user_id: '618976181026422814',
  type: 0,
  message_id: '1307361477182754877',
  message_author_id: '618976181026422814',
  member: {
    user: {
      username: 'jiralite',
      public_flags: 4210944,
      id: '618976181026422814',
      global_name: 'Jiralite',
      display_name: 'Jiralite',
      discriminator: '0',
      clan: null,
      bot: false,
      avatar_decoration_data: null,
      avatar: '096240dfad1c926c33f0a92b111aaaeb'
    },
    roles: [],
    premium_since: null,
    pending: false,
    nick: null,
    mute: false,
    joined_at: '2024-06-08T17:57:51.599000+00:00',
    flags: 0,
    deaf: false,
    communication_disabled_until: null,
    banner: null,
    avatar: null
  },
  emoji: { name: 'SkyLook', id: '649013670625542155' },
  channel_id: '1089254519268974712',
  burst: false,
  guild_id: '1089217648996401242'
}

This data is shoved into the cache here:

const reaction = message.reactions._add({
emoji: data.emoji,
count: message.partial ? null : 0,
me: user.id === this.client.user.id,
burst_colors: data.burst_colors,
});

burst_colors is not here, but we make sure the property exists. This means here, it's set to undefined:

if ('burst_colors' in data) {
/**
* Hexadecimal colors used for this super reaction
* @type {?string[]}
*/
this.burstColors = data.burst_colors;
}

me_burst is also not here, which means this is undefined too:

Interestingly, there does not seem to be a way for bots to burst react, so doing Boolean(data.me_burst) should be enough. For burst_colors... since that is always present, I've added an array check. If it's not an array, then it's likely missing and should be left alone.

Tested also with no partials and [Partials.Channel, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.Message, Partials.Reaction, Partials.ThreadMember, Partials.User].

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@Jiralite Jiralite requested a review from a team as a code owner November 16, 2024 15:49
@vercel
Copy link

vercel bot commented Nov 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Nov 18, 2024 11:08am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 18, 2024 11:08am

@kodiakhq kodiakhq bot merged commit 2fa7d62 into main Nov 18, 2024
25 checks passed
@kodiakhq kodiakhq bot deleted the fix/undefined-bursts branch November 18, 2024 11:14
Jiralite added a commit that referenced this pull request Nov 18, 2024
* fix(MessageReaction): `undefined` burst properties

* refactor: simpler burst colour check

Co-authored-by: Almeida <[email protected]>

---------

Co-authored-by: Almeida <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants