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 works6 Replies
• 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.category.children.cache returns a collection of channels in that category
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()]
Ah alrighty cool
Will the cache always be populated?
if you have the Guilds intent
yes
Great tysm