Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

313
Vistas
Discord JS - Counting voice and text channels

Trying to make a counter for text and voice channels. So it should exclude the amoount of categories.

module.exports = async (client) => {
  const guild = client.guilds.cache.get('912706237806829598');

  setInterval(async () => {
    const channelCount = (await guild.channels.fetch()).filter(
      (channel) => channel.type !== 'category'
    ).size;
    const channel = guild.channels.cache.get('960790479925039124');
    channel.setName(`╭🎚・Channels: ${channelCount.toLocaleString()}`);
    console.log('Updating Channel Count');
    console.log(channelCount);
  }, 600000);
};

This gives me 183 which is wrong. The number I want to achieve is 155. I have 28 categories, so 183 makes sense if the categories aren't filtered. Filtering the categories has been a bigger struggle that I anticipated.

I have also tried to filter on the cache. guild.channels.cache.filter(channel => channel.type !== 'category').size; but it results in the same way (183). So the filtering isn't working as intended.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you're using discord.js v13+, channel types are now uppercase and align with Discord's naming conventions. See below the changes:

channel type v12 v13
DM channel dm DM
group DM channel N/A GROUP_DM
guild text channel text GUILD_TEXT
guild text channel's public thread channel N/A GUILD_PUBLIC_THREAD
guild text channel's private thread channel N/A GUILD_PRIVATE_THREAD
guild voice channel voice GUILD_VOICE
guild stage voice channel N/A GUILD_STAGE_VOICE
guild category channel category GUILD_CATEGORY
guild news channel news GUILD_NEWS
guild news channel's public thread channel N/A GUILD_NEWS_THREAD
guild store channel store GUILD_STORE
generic channel of unknown type unknown UNKNOWN

As you can see, category is now GUILD_CATEGORY. It means, your filter (channel.type !== 'category') won't match anything, as there is no category type anymore. To fix this, you can use the following:

const channelCount = (await guild.channels.fetch()).filter(
  (channel) => channel.type !== 'GUILD_CATEGORY'
).size;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda