Q: Discord.js How would I create a bot status announcement? I need some code that would allow me to send a webhook across the servers my bot is in.
Like how the bot "Dank Memer" has webhooks sent to servers it's in about the status of the bot.
For example:
"Dank Memer Official #bot-status SERVER 01/18/2021
We are waiting to hear back from our host on this issue. Most of the bot is online, but performing badly.
I would suggest not using it until this is fixed, there will likely be weird bugs with this type of latency."
When I check out the discord server all the person does is send a message in the channel, and it sends that message throughout the servers in a specific channel.
All I have is:
module.exports = {
name: 'announce',
description: 'Sends a webhook annoucment to the channel that I specify',
execute(client, message, args, Discord) {
    const webhookClient = new Discord.WebhookClient('ID', 'Token');
    
    var announcement = "";
    for (const word in args) {
        announcement = announcement + args[word] + " ";
    }
    webhookClient.send(announcement)
}

}

A: I think your error is either from a wrong webhook or a wrong argument selection.
This code should work, let me know if not!
module.exports = {
    name: 'announce',
    description: 'Sends a webhook annoucment to the channel that I specify',
    execute(client, message, args, Discord) {
        const webhookChannelID = "Put your channel ID here";
        const channel = message.guild.channels.cache.get(webhookChannelID)

        const webhooks = await channel.fetchWebhooks();
        const webhook = null;
        if(webhooks.array().length == 0){
            webhook = await channel.createWebhook('Example Webhook');
        }
        else{
            webhook = webhooks.first();
        }
        webhook.send(args.join(" "))
    }
}

