Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Can't check custom status of discord.js user

I'm trying to make a system in discord.js version 12 where if you have my vanity invite in your status, you get a supporter role

Whenever I try this it always says TypeError: Cannot read property 'find' of undefined

Here is my code

const roleID = "MyRoleID"
const inviteLink = "discord.gg/MyVanityInvite"

client.on('presenceUpdate', (_oldPresence, newPresence) => {
  const member = newPresence.member
  if (member) {
    // Ignore members who already have the role
    if (!member.roles.cache.has(roleID)) {
      console.log(newPresence)
      const customStatus = newPresence.activities.find(activity => activity.type === 'CUSTOM_STATUS').state
      if (customStatus) {
        if (customStatus.includes(inviteLink)) {
          member.roles.add(roleID)
            .catch(console.error)
        }
      }
    }
  }
})

If I try to log the newPresence is logs an array

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

<Presence>.activities returns an array of activities, you don't need to get the cache, just find directly like:

newPresence.activities.find(activity => activity.type === 'CUSTOM_STATUS').state
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!