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

Not receiving User Update event #4169

Closed
1 task done
Koyamie opened this issue May 6, 2020 · 5 comments
Closed
1 task done

Not receiving User Update event #4169

Koyamie opened this issue May 6, 2020 · 5 comments

Comments

@Koyamie
Copy link
Contributor

Koyamie commented May 6, 2020

Please describe the problem you are having in as much detail as possible:
It beens few weeks that I am not receiving User Update event when using Gateway Intents.

Include a reproducible code sample here, if possible:

Here is my intents set up code but as User Update event is a passthrough I should still receive it.

const { Intents } = require('discord.js');

const intents = new Intents();

intents.add([
  'GUILDS',
  'GUILD_MEMBERS',
  'GUILD_BANS',
  'GUILD_EMOJIS',
  'GUILD_WEBHOOKS',
  'GUILD_VOICE_STATES',
  'GUILD_MESSAGES',
  'GUILD_MESSAGE_REACTIONS',
  'DIRECT_MESSAGES',
  'DIRECT_MESSAGE_REACTIONS'
]);

[...]

client.on('userUpdate', (oUser, nUser) => {
  console.log(nUser);
});

Note that using eval to execute a bot.emit('userUpdate') works.

Further details:

  • discord.js version: latest master
  • Node.js version: v12.16.3
  • Operating system: debian 9
  • Priority this issue should have – please be realistic and elaborate if possible:
  • I have also tested the issue on latest master, commit hash:
@tiehm
Copy link
Contributor

tiehm commented May 6, 2020

I do not know if that is the fix but maybe you can try it out. I was wondering why my user cache was only my bot on startup and found out that I would need the GUILD_PRESENCES intent to get those.
This might be the same in your case.

@Koyamie
Copy link
Contributor Author

Koyamie commented May 6, 2020

I do not know if that is the fix but maybe you can try it out. I was wondering why my user cache was only my bot on startup and found out that I would need the GUILD_PRESENCES intent to get those.
This might be the same in your case.

Guild Presences is a privileged intent and I do not want to use it, this being said User Update event is not part of Gateway Intents and should still be received so I don't know.

@almostSouji
Copy link
Member

Guild Presences is a privileged intent and I do not want to use it, this being said User Update event is not part of Gateway Intents and should still be received so I don't know.

If you want to use it or not is unfortunately not relevant, if you want the event you will need to get whitelisted or enable the restriction of 100 servers as detailed in the discord API documentation

userUpdate is synthesized by discord.js (line 13 below) internally and stems from presence updates, thus requires that intent.

class PresenceUpdateAction extends Action {
handle(data) {
let user = this.client.users.cache.get(data.user.id);
if (!user && data.user.username) user = this.client.users.add(data.user);
if (!user) return;
if (data.user && data.user.username) {
if (!user.equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
}

The only other place user updates are handled from updates the client user

@iCrawl iCrawl closed this as completed Aug 13, 2020
@advaith1
Copy link
Contributor

We can also trigger userUpdate from guild member updates, there's an open issue about it #4279

imo it would be best to trigger the event from all 3 discord events.

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

No branches or pull requests

6 participants
@advaith1 @tiehm @Koyamie @iCrawl @almostSouji and others