I'm trying to make a command so when you go ;listservers it brings a list of current servers the bot is in but my code is sending servers one at a time making it really slow is there anyway I could fix this? this is my current code
message.channel.send(`Found ${client.guilds.cache.size} servers\nServer List:`)
client.guilds.cache.forEach(guild => {
message.channel.send(`${guild.name} | ${guild.id}`)
})
CodePudding user response:
To list all servers in one message you can just use one line of code:
message.channel.send(client.guilds.cache.map(m => `${m.name} | ${m.id}`).join("\n"))