From 3e1a441ee42d36c26353163d34190d0026dc9d1d Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:46:28 +1100 Subject: [PATCH] Change Advertisement rule to ban from mute --- src/components/Automod.ts | 4 ++-- src/events/messageCreate.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Automod.ts b/src/components/Automod.ts index 278660d..285b270 100644 --- a/src/components/Automod.ts +++ b/src/components/Automod.ts @@ -4,7 +4,7 @@ import Logger from '../helpers/Logger.js'; export default class Automoderator { private static lockQuery:Set = new Set(); static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join(''); - static async repeatedMessages(client:TClient, message:Discord.Message, thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) { + static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) { const now = Date.now(); if (!client.repeatedMessages[message.author.id]) client.repeatedMessages[message.author.id] = {type: type, count:1, firstTime:now, timeout: null}; @@ -18,7 +18,7 @@ export default class Automoderator { if (!this.lockQuery.has(message.author.id)) { this.lockQuery.add(message.author.id); Logger.console('log', 'AUTOMOD', `Lock acquired for ${message.author.tag} with reason: ${reason}`); - await client.punishments.punishmentAdd('mute', {time: duration}, client.user.id, `AUTOMOD:${reason}`, message.author, message.member as Discord.GuildMember); + await client.punishments.punishmentAdd(action, {time: duration}, client.user.id, `AUTOMOD:${reason}`, message.author, message.member as Discord.GuildMember); setTimeout(()=>{ this.lockQuery.delete(message.author.id); Logger.console('log', 'AUTOMOD', `Lock released for ${message.author.tag}`); diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index b7effe1..5796b71 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -21,7 +21,7 @@ export default class MessageCreate { automodded = true; message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PROHIBITEDWORDS', automodFailReason)); message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 10000)); - await Automoderator.repeatedMessages(client, message, 30000, 3, 'bw', '30m', 'Prohibited word spam'); + await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam'); } }, discordInvite: { @@ -32,7 +32,7 @@ export default class MessageCreate { automodded = true; message.delete().catch(()=>Logger.console('log', 'AUTOMOD:ADVERTISEMENT', automodFailReason)); message.channel.send('Please don\'t advertise other Discord servers.').then(x=>setTimeout(()=>x.delete(), 15000)); - await Automoderator.repeatedMessages(client, message, 60000, 2, 'adv', '1h', 'Discord advertisement'); + await Automoderator.repeatedMessages(client, message, 'ban', 60000, 4, 'adv', null, 'Discord advertisement'); } } },