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

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

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