📅  最后修改于: 2022-03-11 15:04:03.283000             🧑  作者: Mango
bot.guilds.cache.forEach((guild) => {
console.log(guild.name);
//This would make the client to send a message "Announcement!" to a channel named "news" in every server, if such a channel didn't exist in a guild, the message wouldn't be sent for that exact guild
try {
guild.channels.cache.find((x) => x.name == 'news').send('Announcement!');
} catch {
//If message couldn't be sent
console.log("Message wasn't sent for " + guild.name);
}
});