📜  所有服务器机器人的公告都在 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:03.283000             🧑  作者: Mango

代码示例1
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);
 }
});