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

205
Visualizações
Member counter is not updating members count discord.js

I created a member counter, but it is not updating. it's stuck on 80585. When I want to update it, I need to restart the bot.

My code:

client.on("ready", async() => {

    let servercount = await client.guilds.cache.reduce((a,b) => a+b.memberCount, 0 );
    
    const activities = [
        `${servercount} People👤 !`,
        `d!help`
    ]
    setInterval(() => {
        const status = activities[Math.floor(Math.random()*activities.length)];
        client.user.setPresence({ status: "online", activities : [{name : `${status}` , type : "WATCHING",}]});
    }, 120000);
});

I am using discord.js v13 and node.js v16enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When I want to update it, I need to restart the bot.

And therein is the issue with your code. Look at the let servercount line. Specifically, look at where it is in your code. The member count is only updating when the bot starts up, because you are only getting the member count when the bot starts up. To fix that particular issue, just move that line into the interval:

client.on("ready", async() => {

    setInterval(async () => {

        let servercount = await client.guilds.cache.reduce((a,b) => a+b.memberCount, 0 );
    
        const activities = [
            `${servercount} People👤 !`,
            `d!help`
        ]

        const status = activities[Math.floor(Math.random()*activities.length)];
        client.user.setPresence({ status: "online", activities : [{name : `${status}` , type : "WATCHING",}]});
    }, 120000);
});

This should at least fix the member count not being updated. However, the member count may still not be up-to-date even after this fix. You need to fetch the member collection of each guild in order to always get accurate numbers.

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