📌  相关文章
📜  在每个公会 discord.js 中发送消息 - Javascript 代码示例

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

代码示例1
if (command === "sendguildmessages") {
  if (message.author.id === "231956829159161856") {
    try {
      let toSay = "messageToSend"
      this.client.guilds.map((guild) => {
        let found = 0
        guild.channels.map((c) => {
          if (found === 0) {
            if (c.type === "text") {
              if (c.permissionsFor(this.client.user).has("VIEW_CHANNEL") === true) {
                if (c.permissionsFor(this.client.user).has("SEND_MESSAGES") === true) {
                  c.send(toSay);
                  found = 1;
                }
              }
            }
          }
        });
      });
    }
    catch (err) {
      console.log("Could not send message to a (few) guild(s)!");
    }
  } else {
    message.reply("You cant do that!")
  }
}