#presenceupdate event
1 messages ยท Page 1 of 1 (latest)
aight
presenceupdate event
yeah the if(newMember.presence) ... wont run because newMember is actually a presence
<:_:874569360642019349> (event) Client#presenceUpdate
Emitted whenever a guild member's presence (e.g. status, activity) is changed.
the previous lines work because Presences have the user property
actually newmember.presence returns null
yup i was correct
newMember and oldMember are both instances of a Presence
so <Presence>.presence is the cause
ic, so can you say me where i have gone wrong ?
line 14 in the previous bin
i tried refering to the docs and doing this but seems like i went wrong somewhere
if(newMember.presence) ...
is actually
if(presence.presence) ...
so it doesnt make sense
ic so newmember is presence basically
yup
so is oldMember
both are presences
also in your
constructor(...args) {
super(...args, {
once: true
});
}
https://sourceb.in/H03EAlmbGv my current code rn
i assume you dont want the event to run only once
yeah true
newMember is already a presence why are you calling .member.presence on it?
i checked the docs, it seems like its related to member ?
so should i just get to the point instead ?
like presence .presence
oh
this was the method my friend teached me to do to prevent offline peeps
yeah
ic
you can just do optional chaining
if (<Presence>?.<prop>) ...
also i suggest that you name your function parameters (new|old)Presence
(new|old)Member is misleading and can cause you to assume the parameters are of a different type
np ๐
if i have further doubts, ill prolly ask in #djs-help-v14
once again thanks a lot!
aite good luck ๐
thank you
@agile quartz hey i hope u don't mind me pinging, but uh i noticed that i changed my status and didn't work much, what i mean is, it didn't show my name ...
does the event get emitted?
yeah it does, it seems like it works for some other kinda game presence i g
if it does then its probably one of your checks not being correct
i am not sure where I've gone wrong but when i tried this method with uh client
it worked
this.client.guilds.cache.forEach(guild => {
guild.members.cache.forEach(member => {
if (member.presence) {
if (member.presence.activities[0]) {
if (member.presence.activities[0].state) {
if (member.presence.activities[0].state.includes("brats")) {
let role = guild.roles.cache.get('906366377990971412');
member.roles.add(role)
} else if (member.roles.cache.get("906366377990971412")) {
let role = guild.roles.cache.get('906366377990971412');
member.roles.remove(role)
}
}
}
}
})
})``` basically smth like this
you are probably looking for Presence#status and not state
i mean state and status is the same thing or is it like diff ?
it is different
oh i c
so atm i have my status a songs name, uh so if i need to get that should i use state or status
wait a sec
Activity {
id: 'custom',
name: 'Custom Status',
type: 'CUSTOM',
url: null,
details: null,
state: 'sTOP SPAMMING MY DMS I WANT TO PLAY BP WITH MORGAN AND THREESOME WITH AMORE',
applicationId: null,
timestamps: null,
syncId: null,
platform: null,
party: null,
assets: null,
flags: ActivityFlags { bitfield: 0 },
emoji: null,
sessionId: null,
buttons: [],
createdTimestamp: 1640755130185
}```
state seems like the status to me tbh
ah i see
i actually console logged (member.presence.activities[0]
oh wait
seems like state is the one but it just doesn't passes it
oh
mb
i was in a rush didn't notice that 
It works now, im sorry for that oml, didn't notice that []
ye dw about it just make sure you check your code properly next time
yes i will!
thanks for ur help ocne again! appreciate it
and sorry for the ping 
no
