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

209
Views
how to change the activities title *Respectively* in discord.js?

hey i wanna do something on discord.js but just don't know how, i know that it's possible but idk how so i wanted to ask ya guys that: i wanna set my bot's activity like it's keep being changed respectively not randomly. it shouldn't be randomly because....uhhh....you'll realize soon ._.

here's my activity's codes but it's in randomly(i want it to be respectively as i said):

client.on("ready") {
        console.log('Boom bot is ready to boom!')
        setInterval(() => {
            var v = (client.guilds.cache.size)
            const count = [
                "1", "2", "3", "BOOM!"]
            // here it collects the titles in randomly
            const number = Math.floor(Math.random()*(count.length))
            const activity = count[number]
            
            client.user.setActivity(activity);
        };
    })

if anybody here knows how to get the numbers of number variable respectively, plz consider helping this guy👍🏻

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try a couple things: declare the desired statuses outside of the setInterval function. Also set an interval in ms for the interval to execute on. This is done by adding a comma and then the number of milliseconds to wait before executing again. Declare the desired index outside of the function and then inside the function reset the index to zero once you've iterated through the whole array.

const count = ["1", "2", "3", "BOOM!"] //removed outside
let index = 0; //declaring an index
setInterval(() => {
            // here it collects the titles in randomly
            const activity = count[index] //accessing array at index
            index++; //incrementing
            if (index >= count.length) index = 0; //resetting
            console.log(activity);
            }, 1000); //setting an interval
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!