block repeat infraction executions for the same user
This commit is contained in:
parent
2ce53caead
commit
c85ae1d48d
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user