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

114
Views
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 answers
Answer question

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 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!