showing results for - "send a message in every guild discord js"
Acacia
15 Jun 2017
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