From b040aad719a660863ceb465ca6f3c2731e49c7da Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:23:45 +1000 Subject: [PATCH] Cleanup old automod rule --- src/components/Automod.ts | 21 +-------------------- src/events/messageCreate.ts | 14 -------------- src/models/MPServer.ts | 8 ++++---- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/components/Automod.ts b/src/components/Automod.ts index d661883..c428c9b 100644 --- a/src/components/Automod.ts +++ b/src/components/Automod.ts @@ -36,26 +36,7 @@ export default class Automoderator { clearTimeout(data.timeout); data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime); } - }/* - static isSpam(client:TClient, message:Discord.Message, threshold:number): boolean { - const now = Date.now(); - const time = 30000; - - if (!client.repeatedMessages[message.author.id]) client.repeatedMessages[message.author.id] = {type: 'spam', count: 1, firstTime: now, timeout: null}; - else { - const data = client.repeatedMessages[message.author.id]; - if (now - data.firstTime < time) { - data.count++; - if (data.count >= threshold) return true; - } else { - data.count = 1; - data.firstTime = now; - } - clearTimeout(data.timeout); - data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], time); - } - return false; - }*/ + } static async imageOnly(message:Discord.Message) { const io_channels = ['468896467688620032']; let deleteReason:string = 'This is an image-only channel and your message did not contain any images.'; diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index bf946ab..42b20bd 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -43,17 +43,6 @@ export default class MessageCreate { await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam'); } }, - /*{ - name: 'messageSpam', - check: ()=>Automoderator.isSpam(client, message, 6) && !MessageTool.isStaff(message.member as Discord.GuildMember), - action: async()=>{ - automodded = true; - message.delete().catch(()=>Logger.console('log', `${automodLog}MessageSpam`, automodFailReason)); - message.channel.send('Spamming is not cool, slow down!').then(x=>setTimeout(()=>x.delete(), 15000)); - await Automoderator.repeatedMessages(client, message, 'mute', 5000, 2, 'spam', '30m', 'Message spam'); - delete client.repeatedMessages[message.author.id]; - } - },*/ { name: 'discordInvite', check: ()=>message.content.toLowerCase().match(/(https?:\/\/)?(.*?@)?(www\.)?(discord\.(gg)|discord(app)?\.com\/invite)\/(?[\w-]+)/ui) && !MessageTool.isStaff(message.member as Discord.GuildMember), @@ -79,9 +68,6 @@ export default class MessageCreate { } }; if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id); - // Mop gifs from banned channels without admins having to mop them. - // const bannedChannels = [] - // if (['tenor.com/view', 'giphy.com/gifs', 'giphy.com/media'].some(e=>message.content.toLowerCase().includes(e)) && bannedChannels.includes(message.channelId)) message.reply('Gifs are not allowed in this channel.').then(()=>message.delete()) // Autoresponse:tm: if (client.config.botSwitches.autores && !automodded) { diff --git a/src/models/MPServer.ts b/src/models/MPServer.ts index 1b1ce8a..f33d482 100644 --- a/src/models/MPServer.ts +++ b/src/models/MPServer.ts @@ -85,10 +85,10 @@ export class MPServerSvc { async incrementPlayerCount(serverName:string, playerCount:number) { const server = await this.model.findOne({where: {serverName}}); if (server) { - let PD = server.dataValues.playerData; - if (PD.length > 1920) PD = []; //Selfnote: 86400/45 = 1920, where 86400 is seconds in a day and 45 is the MPModule's refresh interval. - PD.push(playerCount); - await this.model.update({playerData: PD}, {where: {serverName}}); + let playerData = server.dataValues.playerData; + if (playerData.length > 1920) playerData = []; //Selfnote: 86400/45 = 1920, where 86400 is seconds in a day and 45 is the MPModule's refresh interval. + playerData.push(playerCount); + await this.model.update({playerData}, {where: {serverName}}); return true; } return false;