25 lines
No EOL
608 B
JavaScript
25 lines
No EOL
608 B
JavaScript
import { Client, GatewayIntentBits } from "discord.js";
|
|
import { config } from "../static/config.js";
|
|
|
|
const client = new Client({
|
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
|
|
});
|
|
|
|
async function initDiscordBot() {
|
|
await client.login(config.token);
|
|
console.log("✅ Discord bot connecté !");
|
|
}
|
|
|
|
async function sendDiscordAlert(message) {
|
|
try {
|
|
const channel = await client.channels.fetch(config.textChannelId);
|
|
await channel.send(message);
|
|
} catch (err) {
|
|
console.error("❌ Erreur envoi Discord :", err);
|
|
}
|
|
}
|
|
|
|
export {
|
|
initDiscordBot,
|
|
sendDiscordAlert
|
|
} |