Iterating category children

How can I iterate the channels in a category channel in v14? Previously I did for(const [_, channel] of category.children) but this no longer works
6 Replies
d.js docs
d.js docs2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
chewie 🌈
chewie 🌈2y ago
category.children.cache returns a collection of channels in that category
d.js docs
d.js docs2y ago
Converting a Collection to an array You only need to convert it to an array if you need the index of an entry: • Iteration (looping) is possible with for...of over Collection#values or forEach • You can transform a Collection to an array with Collection#map • If you need indices, you can get the array using [...collection.values()]
jr
jr2y ago
Ah alrighty cool Will the cache always be populated?
chewie 🌈
chewie 🌈2y ago
if you have the Guilds intent yes
jr
jr2y ago
Great tysm