diff --git a/structure/client/components/observers/Automoderation.js b/structure/client/components/observers/Automoderation.js index 7ef1a0c..18ca420 100644 --- a/structure/client/components/observers/Automoderation.js +++ b/structure/client/components/observers/Automoderation.js @@ -45,12 +45,19 @@ module.exports = class AutoModeration extends Observer { ]; this.whitelist = new BinaryTree(this.client, FilterPresets.whitelist); + this.executing = {}; } async _moderate(action, guild, channel, member, reason, filterResult) { + + // Prevent simultaneous execution of the same filter on the same user when spamming + if (!this.executing[filterResult.filter]) this.executing[filterResult.filter] = []; + if (this.executing[filterResult.filter].includes(member.id)) return; + this.executing[filterResult.filter].push(member.id); + const InfractionClass = CONSTANTS.Infractions[action.type]; - return this.client.moderationManager._handleTarget(InfractionClass, member, { + const result = await this.client.moderationManager._handleTarget(InfractionClass, member, { guild, channel, executor: guild.me, @@ -63,7 +70,10 @@ module.exports = class AutoModeration extends Observer { data: { automoderation: filterResult } - }); + }).catch(this.client.logger.error.bind(this.client.logger)); + + await Util.wait(5000); + this.executing[filterResult.filter].splice(this.executing[filterResult.filter].indexOf(member.id), 1); } @@ -399,6 +409,7 @@ module.exports = class AutoModeration extends Observer { this.client.rateLimiter.queueDelete(msg.channel, msg); //msg.delete(); + filterResult.filter = 'link'; this._moderate(action, guild, channel, member, msg.format('L_FILTER_ACTION', { domain: filterResult.match }), filterResult, message); } else this.client.rateLimiter.queueDelete(msg.channel, msg); //msg.delete();