Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda