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
#shouldnt i receive a presenceUpdate event when an user updates their username?
45 messages · Page 1 of 1 (latest)
• 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)
(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.
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
djs follows naming literally, so presenceUpdate emits when presence data changes, ie status and activities
actually not sure about this, don't remember specifics on this anymore. that might not be a valid answer, sorry.
i dont think thats triggered by users updating their usernames tho
well ill just test it
yeah nothing happened in neither presenceUpdate nor guildMemberUpdate when i updated my username
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
doing that for every username update would put a huge strain on my server i dont think i can do that
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
mm yeah that seems quite expensive
what about doing the check prior to checking for the member existing
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
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
it's still the same network load, just through ws instead of through http
it isnt because without the event i have to try to fetch for every guild even those that the user is not in (because i dont know in which guilds they are)
no you don't
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
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
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
ill do some tests to evaluate the cost of this approach
but thanks for the help

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
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