Discord.js: Not receiving User Update event

Created on 6 May 2020  Â·  5Comments  Â·  Source: discordjs/discord.js

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:
  • [x] I have also tested the issue on latest master, commit hash:
unverified bug

Most helpful comment

I'm having the same exact issue

Main.ts

Main.on('userUpdate', function(oUser, nUser) {
    NickSpamHandler.NickHandle(oUser, nUser)
})

NickSpamTask.ts

import Discord, { Message, MessageFlags, GuildMember, PartialUser } from 'discord.js'
import { Context } from '../Handler/Context';
import User from 'discord.js';

export class NickAntiRaid {
    private messages : Message[];
    private message: Message
    private readonly prefix: string;
    private

    constructor(prefix: string) {
        this.prefix = prefix
    }

    async NickHandle(oUser : Discord.User | Discord.PartialUser, nUser: Discord.User | Discord.PartialUser) {
        console.log('Test')

    }
}

All 5 comments

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.

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.

I'm having the same exact issue

Main.ts

Main.on('userUpdate', function(oUser, nUser) {
    NickSpamHandler.NickHandle(oUser, nUser)
})

NickSpamTask.ts

import Discord, { Message, MessageFlags, GuildMember, PartialUser } from 'discord.js'
import { Context } from '../Handler/Context';
import User from 'discord.js';

export class NickAntiRaid {
    private messages : Message[];
    private message: Message
    private readonly prefix: string;
    private

    constructor(prefix: string) {
        this.prefix = prefix
    }

    async NickHandle(oUser : Discord.User | Discord.PartialUser, nUser: Discord.User | Discord.PartialUser) {
        console.log('Test')

    }
}

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.

https://github.com/discordjs/discord.js/blob/d827544fbd12e827fb4b6ff99d8894ecd79ede02/src/client/actions/PresenceUpdate.js#L6-L14

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Brawaru picture Brawaru  Â·  3Comments

DatMayo picture DatMayo  Â·  3Comments

xCuzImPro picture xCuzImPro  Â·  3Comments

shukriadams picture shukriadams  Â·  3Comments

tom-barnes picture tom-barnes  Â·  3Comments