Discord.js: userUpdate fires multiple times instead of only once

Created on 28 Aug 2017  ·  11Comments  ·  Source: discordjs/discord.js

Hi,

it seems that userUpdate fires more than just once, it fires the same amount of guilds in common. (This should be done by guildMemberUpdate, right?)
This seems like a bug, because after the first fire, oldUser and newUser don't differ anymore.

Also userUpdate fires on a user's presence update, but oldUser and newUser have the same presence set (the new presence).

Given the following code with 3 servers in common:

console.log(oldUser.presence.status);
console.log(newUser.presence.status);
console.log('---');

On a presence update, the output is:

idle
---
online
online
---
online
online
---

With the code modified to display the tag:

console.log(oldUser.tag);
console.log(newUser.tag);
console.log('---');

and a following username update, the output is:

testuser-1#9911
testuser#9911
---
testuser#9911
testuser#9911
---
testuser#9911
testuser#9911
---

Further details:

  • discord.js version: latest master b7c55f02c20bee5dab107ff453a6d3ea1a4a776a
  • node.js version: 8.3.0
  • Operating system: W10 x64
  • Priority this issue should have – please be realistic and elaborate if possible: low-ish?
unverified caching bug

Most helpful comment

I saw it in the docs, that's why I edited my message, sorry for that!

All 11 comments

Fixed on e686c9a8166b14235060050962eae9b2b835e4c1, we can't do much for presences because technically, within the API, members have presences and not users.

Although I guess it technically is fixed since userUpdate now emits correctly, as now the presence will only change once.

Hmmm updating to the latest commit caused pm messages not to trigger the message event anymore and even the userUpdate event (tried with changing profile pic) :(

setGame is now setActivity.

I saw it in the docs, that's why I edited my message, sorry for that!

Okay, those two events not firing were my fault due to another api change...

userUpdate now fires correctly (tried changing nicks and profile pictures for testing guildMemberUpdate). However: It does not fire if a user sets his initial avatar or removes his/her avatar.

Further testing revealed that creating / changing / deleting the avatar triggers presenceUpdate

Fixed in the commit I just pushed, thanks for spotting this! 👍

Okay that fixed it, thanks! I assume that a fired presenceUpdate for changing the avatar is intentional?

Yep! All user changes also trigger a presenceUpdate.

Okay! Thanks for clarification 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smchase picture smchase  ·  3Comments

DatMayo picture DatMayo  ·  3Comments

xCuzImPro picture xCuzImPro  ·  3Comments

kvn1351 picture kvn1351  ·  3Comments

iCrawl picture iCrawl  ·  3Comments