Answers for "announcement for all server bot is in"

0

announcement for all server bot is in

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);
 }
});
Posted by: Guest on July-09-2021

Code answers related to "announcement for all server bot is in"

Code answers related to "Javascript"

Browse Popular Code Answers by Language