discord js how to send a message to all guilds

Solutions on MaxInterview for discord js how to send a message to all guilds by the best coders in the world

showing results for - "discord js how to send a message to all guilds"
Luisa
19 Nov 2018
1if (command === "sendguildmessages") {
2  if (message.author.id === "231956829159161856") {
3    try {
4      let toSay = "messageToSend"
5      this.client.guilds.map((guild) => {
6        let found = 0
7        guild.channels.map((c) => {
8          if (found === 0) {
9            if (c.type === "text") {
10              if (c.permissionsFor(this.client.user).has("VIEW_CHANNEL") === true) {
11                if (c.permissionsFor(this.client.user).has("SEND_MESSAGES") === true) {
12                  c.send(toSay);
13                  found = 1;
14                }
15              }
16            }
17          }
18        });
19      });
20    }
21    catch (err) {
22      console.log("Could not send message to a (few) guild(s)!");
23    }
24  } else {
25    message.reply("You cant do that!")
26  }
27}
28