#presenceupdate event

1 messages ยท Page 1 of 1 (latest)

agile quartz
#

hi can you send the whole code for the event

#

in a bin

surreal quarry
#

aight

agile quartz
#

presenceupdate event

surreal quarry
#

i hope this helps sip

agile quartz
#

yeah the if(newMember.presence) ... wont run because newMember is actually a presence

rugged scarabBOT
#

<:_:874569360642019349> (event) Client#presenceUpdate
Emitted whenever a guild member's presence (e.g. status, activity) is changed.

agile quartz
#

the previous lines work because Presences have the user property

surreal quarry
agile quartz
#

can you log newMember

#

and show the output

surreal quarry
#

i actually missed smth in the newmember part

#

alright give me a sec

agile quartz
#

yup i was correct

#

newMember and oldMember are both instances of a Presence

#

so <Presence>.presence is the cause

surreal quarry
#

ic, so can you say me where i have gone wrong ?

agile quartz
#

line 14 in the previous bin

surreal quarry
#

i tried refering to the docs and doing this but seems like i went wrong somewhere

agile quartz
#

if(newMember.presence) ...

#

is actually

#

if(presence.presence) ...

#

so it doesnt make sense

surreal quarry
#

ic so newmember is presence basically

agile quartz
#

yup

#

so is oldMember

#

both are presences

#

also in your

#
constructor(...args) {
        super(...args, {
            once: true
        });
    }
surreal quarry
agile quartz
#

i assume you dont want the event to run only once

surreal quarry
#

yeah true

agile quartz
#

newMember is already a presence why are you calling .member.presence on it?

surreal quarry
#

so should i just get to the point instead ?

#

like presence .presence

agile quartz
#

you are just doing a large round about

#

let me illustrate

surreal quarry
#

oh

agile quartz
surreal quarry
#

omg this was the method my friend teached me to do to prevent offline peeps

agile quartz
#

yeah

agile quartz
#

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

surreal quarry
#

alright

#

i understood, thanks for ur help and ur time AG_Bow

agile quartz
#

np ๐Ÿ‘

surreal quarry
#

once again thanks a lot!

agile quartz
#

aite good luck ๐Ÿ‘

surreal quarry
#

thank you

surreal quarry
#

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

agile quartz
#

does the event get emitted?

surreal quarry
#

yeah it does, it seems like it works for some other kinda game presence i g

agile quartz
#

if it does then its probably one of your checks not being correct

surreal quarry
#

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
agile quartz
#

you are probably looking for Presence#status and not state

surreal quarry
agile quartz
#

it is different

surreal quarry
#

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

agile quartz
#

status?

#

state is the WATCHING, PLAYING thing

#

iirc

surreal quarry
#

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

agile quartz
#

ah i see

surreal quarry
#

i actually console logged (member.presence.activities[0]

agile quartz
#

oh wait

surreal quarry
#

seems like state is the one but it just doesn't passes it

agile quartz
#

you are using includes wrongly

#

() not []

surreal quarry
#

oh

#

mb

#

i was in a rush didn't notice that omg

#

It works now, im sorry for that oml, didn't notice that []

agile quartz
#

ye dw about it just make sure you check your code properly next time

surreal quarry
#

yes i will!

#

thanks for ur help ocne again! appreciate it

#

and sorry for the ping AG_Bow

agile quartz
#

no