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 docs3y 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
chewie3y ago
category.children.cache returns a collection of channels in that category
d.js docs
d.js docs3y 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
jrOP3y ago
Ah alrighty cool Will the cache always be populated?
chewie
chewie3y ago
if you have the Guilds intent yes
jr
jrOP3y ago
Great tysm
Want results from more Discord servers?
Add your server