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

115
Vistas
Discord.js presenceUpdate firing multiple times

client.on('presenceUpdate', (oldPresence, newPresence) => {
  if (!newPresence.activities) return false;
  newPresence.activities.forEach(activity => {
    if (activity.type == 'STREAMING') {
      //Do stuff if someone starts a stream
    }

I've been developing a Discord bot for my friend's Discord server which automatically notifies, if someone starts streaming. Everything was working fine and dandy, but then yesterday something that I cannot comprehend happened.

A person started streaming and the bot saw that, so it sent a message notifying people like it should. However, that same stream was nearing its end, when the bot decided "I'm gonne send 2 more notifications that the stream has started". These notifications were minute apart from each other.

Could someone please help me with this issue? I've provided a small code snippet from my code which checks if a person starts streaming. Is there a way to stop the bot from sending any more notifications if the user has been streaming? I'd only like the bot to notify about this once when someone starts streaming, not multiple times concerning one specific stream.

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

0

presenceUpdate would also emit, when someone goes into dnd or idle, as well as, when switching game.

So your case could be that the streamer either went idle and online, or switched application wich updated his activites and so their presence.

A possible fix would be to have a database ( or a temporary collection ) which tracks the active streamers so it only sends one message per stream and then waits until the stream is stopped.

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