Initial commit
This commit is contained in:
commit
0dabb7c3c0
7 changed files with 924 additions and 0 deletions
25
src/features/discordBot.js
Normal file
25
src/features/discordBot.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue