Getting number of Category's in a guild discord.js V13

Nicky

For my bot I am making a server info command, currently I can't seem to get the number of category's in a guild so when a user runs !serverinfo there is an embed and under Categorys will display a number. Currently the number that is displayed is 0. How do I fix this?

Code

 const channels = message.guild.channels.cache;

  const embed = new MessageEmbed()
  .setAuthor(message.guild.name, message.guild.iconURL({dynamic: true}))
  .setThumbnail(message.guild.iconURL({dynaic: true}))
  .addField(`Owner`, `${owner.user.tag}`,true)
  .addField(`Categorys`, `${channels.filter(channel => channel.type === "category").size}`,true)
NotTrixxie

You should get the amount of categories with

message.guild.channels.cache.filter(ch => ch.type === 'GUILD_CATEGORY').size

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related