diff --git a/.gitignore b/.gitignore index 7df15e8..c55b01c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ ips.txt .yarn # TypeScript stuff dist +src/private src/*.json diff --git a/src/components/Automod.ts b/src/components/Automod.ts index de6dc29..9f94544 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, action:'mute'|'ban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) { + static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban'|'softban', 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}; diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 09a7d15..9d0d957 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -5,6 +5,7 @@ import CmdTrigger from '../modules/CmdModule.js'; import Logger from '../helpers/Logger.js'; import ConfigHelper from '../helpers/ConfigHelper.js'; import Automoderator from '../components/Automod.js'; +import __PRIVATE from '../private/_.js'; import MessageTool from '../helpers/MessageTool.js'; export default class MessageCreate { static async run(client:TClient, message:Discord.Message) { @@ -15,12 +16,21 @@ export default class MessageCreate { if (client.config.botSwitches.automod && !message.member.roles.cache.has(client.config.dcServer.roles.dcmod) && !message.member.roles.cache.has(client.config.dcServer.roles.admin) && message.guildId === client.config.dcServer.id) { const automodFailReason = 'msg got possibly deleted by another bot.'; const automodRules = { + phishingDetection: { + check: async()=>await __PRIVATE.phishingDetection(message), + action: async()=>{ + automodded = true; + message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PHISHING', automodFailReason)); + message.channel.send('Phishing links aren\'t allowed here. Nice try though!').then(msg=>setTimeout(()=>msg.delete(), 15000)); + await Automoderator.repeatedMessages(client, message, 'softban', 60000, 2, 'phish', null, 'Phishing/scam link'); + } + }, prohibitedWords: { check: async()=>await client.prohibitedWords.findWord(Automoderator.scanMsg(message)), action: async()=>{ 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)); + message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 15000)); await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam'); } }, diff --git a/src/index.ts b/src/index.ts index 7417774..cc09e95 100644 --- a/src/index.ts +++ b/src/index.ts @@ -108,7 +108,6 @@ client.on('raw', async (packet:RawGatewayPacket)=>{ const channel = client.channels.cache.get(packet.d.channel_id) as Discord.TextBasedChannel; const old_message = await channel.messages.fetch(packet.d.id); const new_message = await channel.messages.fetch(packet.d.id); - if (old_message.content === new_message.content) return; client.emit('messageUpdate', old_message, new_message); });