Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda