#shouldnt i receive a presenceUpdate event when an user updates their username?

45 messages · Page 1 of 1 (latest)

naive marten
#

the discord api docs clearly says a Presence Update event is sent when an user updates their username (see attached image) but it doesnt seem to be working for me
just to be sure i put a console.log at the very top of the event function and nothing shows up when i update my username
i also know the intents are set up correctly because im receiving the logs just fine when i update my status
no i cant just use userUpdate instead i need the member object for each guild and it's impractical for a decently sized bot to loop through every guild trying to fetch a member with certain frequency

#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

#

did i misinterpret the docs somehow?

#

(im talking about the api docs specifically because the djs docs doesnt say exactly what properties should trigger the presenceUpdate event)

wet dawnBOT
#

event (event) Client#userUpdate
Emitted whenever a user's details (e.g. username) are changed. Triggered by the Discord gateway events Events.UserUpdate, Events.GuildMemberUpdate, and Events.PresenceUpdate.

snow dew
#

this part of the handling is a bit weird

#

djs separates out the event depending on what data actually changed

#

anyways, you can use guildMemberUpdate instead

snow dew
snow dew
naive marten
#

well ill just test it

#

yeah nothing happened in neither presenceUpdate nor guildMemberUpdate when i updated my username

snow dew
#

welp you'd need userUpdate then

#

are you trying to make a logger for username changes?

naive marten
#

not really

#

but if i was

#

if i wanted to make it log in every guild the user is in

#

id need to loop through every guild and try to fetch the user as a member right

snow dew
#

yeah

#

so what are you trying to do then?

naive marten
# snow dew yeah

doing that for every username update would put a huge strain on my server i dont think i can do that

naive marten
# snow dew so what are you trying to do then?

my bot has a feature that lets admins basically blacklist substrings from being used in username (slurs, offensive content, etc) but currently im only checking users usernames at the time they join a guild that enabled this feature through the guildMemberAdd event

#

which leaves the simple workaround of joining with an username and then changing it to an offensive one after

#

id like to check usernames on updates too to prevent that

snow dew
#

mm yeah that seems quite expensive

#

what about doing the check prior to checking for the member existing

naive marten
#

if an username update triggered the presenceUpdate event i would receive one for each guild the user shared with my bot and could easily check if their username is blacklisted in one of those guilds

#

wouldnt even have to fetch anything

snow dew
#

with what you've described, sounds like you're planning on doing something like
on username change
for each guild:
check if is member (request)
check if blacklist
kick (request)

you could do something like
on username change
for each guild:
check if blacklist
kick (request)
so much less requests

snow dew
naive marten
snow dew
#

you only have to make the kick request

#

you don't need to fetch prior, since the guild-specific data doesn't matter for this action

naive marten
#

thats true but it's still a kick request for each guild instead of just the ones i know the user is a member of

snow dew
#

that's true, but there's not exactly much data being sent as payload so network strain would be less of a factor

#

as for request count, since it's for separate guilds, iirc they won't stack, and you'll just be limited by the global request and error ratelimits

naive marten
#

but thanks for the help

snow dew
#

good luck

#

im not exactly convinced there's really a good approach to this problem tbh, but seems like we can at least settle for least worst

naive marten
#

i managed to make it work the way i initially wanted through the raw event (it actually receives username updates) but then discord instantly denied my presence intent request because they dont think it's an "unique compelling user facing functionality" so i guess they decided for me