i'm trying to make top server's in members count and this is my code:
const embed = new Discord.MessageEmbed()
.setAuthor({ name: `Top Server's`, iconURL: client.user.displayAvatarURL()})
.setColor('#545db8')
for (i = 0; i < 3; i++) {
let guild = client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).array()[i];
embed.setDescription(`**${i + 1}. ${guild.name}** \n \n Member count: \`${guild.memberCount}\` \n ID: \`${guild.id}\`\n Server Age: <t:${parseInt(guild.createdAt / 1000)}:R>`)
embed.setThumbnail(guild.iconURL())
msg.channel.send({ embeds: [embed] })
}
the error:
TypeError: client.guilds.cache.sort(...).array is not a function
i was using this in v12 and it was working but when i switch to v13 it start showing errors, i've looked up in the discord.js docs but can't find anything
let guild = [...client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).values()][i];
These methods existed to provide access to a cached array of Collection values and keys respectively, which other Collection methods relied on internally. Those other methods have been refactored to no longer rely on cache, so those arrays and these methods have been removed.
You should instead construct an array by spreading the iterators returned by the base Map class methods.