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

158
Views
Serverinfo interaction slash command showing 3 channels, but I have only 2 channels in the server

serverinfo interaction slash command showing 3 channels, but I have only 2 channels in the server. It is including the category too, how I fix it?

Here is the code -

if (commandName === 'serverinfo') {
  let serverinfoembed = new MessageEmbed()
  .setAuthor(`Info for ${interaction.guild.name}`)
  .setColor('#4269f5')
  .addField('Owner', `<@${interaction.guild.ownerId}>`, true)
  .addField('Channels', `${interaction.guild.channels.cache.size}`, true)
  return interaction.reply({ embeds: [serverinfoembed] });
};
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to filter what channels you want to count for example text channels

interaction.guild.channels.cache.filter(ch => ch.type === 'GUILD_TEXT').size

All of the channel types you can see from here

about 4 years ago · Juan Pablo Isaza Report

0

In Discord.js, it counts categories as channels. To filter out categories, you need to do the following:

interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY").size

This will display the amount of cached text and voice channels. Filtering out voice/text channels are just as easy:

//Getting text channels
interaction.guild.channels.cache.filter(c => c.type === "GUILD_TEXT").size
//Getting VCs
interaction.guild.channels.cache.filter(c => c.type === "GUILD_VOICE").size
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!