import { Client, Intents } from "discord.js" import settings from "../../libs/settings.js" import getLogger from "../../libs/logger.js" const log = getLogger("Discord", settings.notifiers.discord.color) export async function start() { log("Starting Discord notifier...") const client = new Client({ intents: [ Intents.FLAGS.DIRECT_MESSAGES ]}) async function sendMessage(msg) { const receivers = await Promise.all(settings.notifiers.discord.receivers.map(id => client.users.fetch(id))) log("Sending messages to:", receivers.map(e => e.tag)) receivers.forEach(async receiver => { await receiver.createDM() await receiver.send(msg) }) } client.once("ready", () => { log(`Logged in as ${client.user.username}`) }) await client.login(settings.notifiers.discord["api-token"]) return sendMessage }