📌  相关文章
📜  向所有服务器发送消息 discord.js - Javascript 代码示例

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

代码示例1
// Using v11.2 of discord.js, should work with v12 too.

const discord = require('discord.js');
const client = new discord.Client();

// So you can see when it's ready
client.on('ready', () => {
    console.log('On Discord!');
});

client.on('message', () => {
    if (message.content === "!sendguildmessages") {
        var guildList = client.guilds.array();
        try {
            guildList.forEach(guild => guild.defaultChannel.send("messageToSend"));
        } catch (err) {
            console.log("Could not send message to " + guild.name);
        }
    }
});