From ccc2b39563abcf41e2f5eb3cbc0040d0ddd2ad08 Mon Sep 17 00:00:00 2001 From: "Rph :3" <11350302+rphsoftware@users.noreply.github.com> Date: Thu, 22 May 2025 22:21:04 +0200 Subject: [PATCH] update --- .gitignore | 4 ++++ index.js | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..469e22e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +config.json +token.txt +ban_config.json +node_modules \ No newline at end of file diff --git a/index.js b/index.js index 042320e..796f260 100644 --- a/index.js +++ b/index.js @@ -7,11 +7,15 @@ const client = new Client({ GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildVoiceStates, - GatewayIntentBits.GuildModeration + GatewayIntentBits.GuildModeration, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMessages ], }); const config = JSON.parse(readFileSync("config.json", "utf-8")); +const banConfig = JSON.parse(readFileSync("ban_config.json", "utf-8")); + await client.login(readFileSync("token.txt", "utf-8").split("\n")[0]); @@ -91,6 +95,38 @@ client.on(Events.ClientReady, async () => { }) }) +client.on(Events.MessageCreate, async m => { + if (!m.guildId) { + console.log("Got non-guild message"); + return; + } + + if (!banConfig[m.guildId]) { + console.log("Got message in", m.guildId, "/", m.channelId, "without ban config setup."); + return; + } + + let channels = banConfig[m.guildId]; + if (channels.includes(m.channelId)) { + try { + const dm = await m.author.createDM(); + await dm.send("You have been banned for sending a message in the bot trap. Mistake? Appeal here: https://forms.gle/r41Qd12A3Df6kbm56"); + } catch(e) { + console.log("Failed to send message", e); + } + try { + await m.guild.bans.create(m.author, { + deleteMessageSeconds: 600, + reason: "Caught in a bot trap like a stupid fly in a glue trap." + }) + } catch(e) { + console.log("Failed to issue ban", e); + } + + return; + } +}); + client.on(Events.VoiceStateUpdate, async (oldState, newState) => { if (oldState.channelId === newState.channelId) return;