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

127
Vistas
discord auto role when status matches

Ive tries some different things to make this work but it's not wanting to work

so am basicly trying to check someones custom status for a specific thing if there is for example .gg/test in it and give them a role than

My code


client.on('presenceUpdate', async (oldPresence, newPresence) => {
  const role = newPresence.guild.roles.cache.get("927284722059595828");
  const member = newPresence.member
  const activities = member.user.presence.activities[0];

  if (activities && (activities.state.includes( ".gg/test" ) || activities.state.includes("discord.gg/test" ))) {
    return newPresence.member.roles.add(role)
  } else {
    if(member.roles.cache.get(role.id)) {
      newPresence.member.roles.remove(role)
    }
  }
})

so can anyone correct the code to the correct format

and if possable make this multi server usable with a command thanks

the error i get

TypeError: Cannot read properties of undefined (reading 'id')
    at Client.<anonymous> (/root/raegay2/boy.js:19:36)
    at Client.emit (node:events:390:28)
    at PresenceUpdateAction.handle (/root/raegay2/node_modules/discord.js/src/client/actions/PresenceUpdate.js:39:19)
    at Object.module.exports [as PRESENCE_UPDATE] (/root/raegay2/node_modules/discord.js/src/client/websocket/handlers/PRESENCE_UPDATE.js:4:33)
    at WebSocketManager.handlePacket (/root/raegay2/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/root/raegay2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/root/raegay2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/root/raegay2/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (node:events:390:28)
    at Receiver.receiverOnMessage (/root/raegay2/node_modules/ws/lib/websocket.js:825:20)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I just tested your code and it worked fine. Did you enable Presence Intent on your bots discord developer page? If you are using Gateway Intents, you must specify the GUILD_PRESENCES intent in order to receive Presence Update events.

about 4 years ago · Juan Pablo Isaza 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