So I've been trying to make this "serverlist" command into an embed but it doesn't work. Anyone can do the command but if the ID matches to the user, then it'll show in which all servers the bot is in, with a member count and server ID and server NAME. Current code (description doesn't work, thats what i need help with):
client.on('message', message => {
if(message.content.startsWith(prefix + "serverlist")) {
message.channel.send(`__Total servers: ${client.guilds.cache.size}__`)
if(message.author.id === '211180841693347840') {
let embed = new Discord.MessageEmbed()
.setTitle('The bot is in these servers:')
.setDescription(client.guilds.cache.forEach((guild) => {
(`**${guild.name}** with ${guild.memberCount} members. ID: \`${guild.id}\``)
}))
message.channel.send(embed)
}}
})
In this example, I map every server into a string with all relevant data.
let servers = client.guilds.cache.map((server) => {
return `**${server.name}** - \`${server.memberCount}\` : *${server.id}*`
})
Then use said string in .setDescription()
.setDescription(servers)
Keep In Mind that if the final result passes the max char size for an embed you will get an error of Invalid Form Body