import "dotenv/config"; import { Client, GatewayIntentBits } from "discord.js"; const TARGET_USER_ID = "541298246971162636"; const LINK_PATTERN = /(?:https?:\/\/|www\.)\S+/i; const WARNING_MESSAGE = "Alerte: Ce lien a été envoyé par Nesta. Ne cliquez SURTOUT PAS s'il y a des gens autour de vous."; if (!process.env.DISCORD_TOKEN) { throw new Error("Missing DISCORD_TOKEN in environment variables."); } const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent], }); client.on("messageCreate", async (message) => { if (message.author.bot) { return; } if (!message.guild) { return; } if (message.author.id !== TARGET_USER_ID) { return; } if (!LINK_PATTERN.test(message.content)) { return; } await message.channel.send(WARNING_MESSAGE); }); client.once("clientReady", () => { console.log(`Logged in as ${client.user.tag}`); }); client.login(process.env.DISCORD_TOKEN);