client.guilds.cache.array()
I am converting my old bot from discord.js v12 to v14. In v12, there was a function client.guilds.cache.array() which does not work in v14. What are the alternative(s) for v14?
5 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.why do you need it to be an array in the first place?
in 9/10 cases using and iterating the collection itself is preferred
I can do collection.forEach?
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()]
so I just do client.guilds.cache?
Oh my bad then
Sorry