diff --git a/structure/client/components/observers/Automoderation.js b/structure/client/components/observers/Automoderation.js index 65d675a..65aec04 100644 --- a/structure/client/components/observers/Automoderation.js +++ b/structure/client/components/observers/Automoderation.js @@ -234,8 +234,9 @@ module.exports = class AutoModeration extends Observer { msg.filtered = filterResult; log += `\nFilter result: ${inspect(filterResult)}`; if (!silent) { - const res = await msg.formattedRespond('W_FILTER_DELETE', { params: { user: author.id } }); - res.delete({ timeout: 10000 }); + const res = await this.client.rateLimiter.limitSend(msg.channel, msg.format('W_FILTER_DELETE', { user: author.id }), undefined, 'wordFilter'); + //const res = await msg.formattedRespond('W_FILTER_DELETE', { params: { user: author.id } }); + if (res) res.delete({ timeout: 10000 }); } // 6. Automated actions @@ -253,49 +254,18 @@ module.exports = class AutoModeration extends Observer { if (!action) { this.client.logger.debug(log); - return msg.delete(); + this.client.rateLimiter.queueDelete(msg.channel, msg); } msg.filtered.sanctioned = true; - msg.delete(); + this.client.rateLimiter.queueDelete(msg.channel, msg); this.client.logger.debug(log + '\nSanctioned'); // NOTE: this will have to be changed whenever the moderation manager is finished and properly supports sth like this this._moderate(action, guild, channel, member, moderationPoints, silent, msg.format('W_FILTER_ACTION'), filterResult, message); - // this.client.moderationManager.handleInfraction( - // CONSTANTS.Infractions[action.type], - // { // Hacky patched together message object with just the required stuff for modmanager to work - // guild, - // member: guild.me, - // channel, - // arguments: { - // force: { - // value: action.force - // }, - // points: { - // value: action.points || moderationPoints.points[action.type] - // }, - // expiration: { - // value: action.expiration || moderationPoints.expirations[action.type] - // }, - // silent: setting.silent - // }, - // format: guild.format.bind(guild), - // // eslint-disable-next-line no-empty-function - // respond: () => { } - // }, - // { - // targets: [member], - // reason: msg.format('W_FILTER_ACTION'), - // duration: action.duration, - // data: { - // filterResult - // } - // } - // ); } else { - msg.delete(); + this.client.rateLimiter.queueDelete(msg.channel, msg); this.client.logger.debug(log); } @@ -406,8 +376,9 @@ module.exports = class AutoModeration extends Observer { if (!remove) return; msg.filtered = filterResult; if (!silent) { - const res = await msg.formattedRespond(`L_FILTER_DELETE`, { params: { user: author.id } }); - res.delete({ timeout: 10000 }); + const res = await this.client.rateLimiter.limitSend(msg.channel, msg.format('L_FILTER_DELETE', { user: author.id }), undefined, 'linkFilter'); + //const res = await msg.formattedRespond(`L_FILTER_DELETE`, { params: { user: author.id } }); + if (res) res.delete({ timeout: 10000 }); } if (actions.length) { @@ -425,11 +396,12 @@ module.exports = class AutoModeration extends Observer { if (!action) return msg.delete(); msg.filtered.sactioned = true; - msg.delete(); + this.client.rateLimiter.queueDelete(msg.channel, msg); + //msg.delete(); this._moderate(action, guild, channel, member, moderationPoints, silent, msg.format('L_FILTER_ACTION'), filterResult, message); - } else msg.delete(); + } else this.client.rateLimiter.queueDelete(msg.channel, msg); //msg.delete(); } @@ -464,51 +436,15 @@ module.exports = class AutoModeration extends Observer { match: match[0], matcher: 'invites' }; - if (!action) return msg.delete(); + if (!action) return this.client.rateLimiter.queueDelete(msg.channel, msg); //msg.delete(); if (!silent) { - const res = await msg.formattedRespond('I_FILTER_DELETE', { params: { user: author.id } }); - res.delete({ timeout: 10000 }); + const res = await this.client.rateLimiter.limitSend(msg.channel, msg.format('I_FILTER_DELETE', { user: author.id }), undefined, 'inviteFilter'); + if (res) res.delete({ timeout: 10000 }); } msg.filtered.sactioned = true; - msg.delete(); + this.client.rateLimiter.queueDelete(msg.channel, msg); this._moderate(action, guild, channel, member, moderationPoints, silent, msg.format('I_FILTER_ACTION'), { filtered: msg.filtered }, message); - // NOTE: this will have to be changed whenever the moderation manager is finished and properly supports sth like this - // this.client.moderationManager.handleInfraction( - // CONSTANTS.Infractions[action.type], - // { - // guild, - // member: guild.me, - // channel, - // arguments: { - // force: { - // value: action.force - // }, - // points: { - // value: action.points || moderationPoints.points[action.type] - // }, - // expiration: { - // value: action.expiration || moderationPoints.expirations[action.type] - // }, - // silent: setting.silent//, - // //prune: { - // // name: 'prune', - // // value: 50 - // //} - // }, - // format: guild.format.bind(guild), - // // eslint-disable-next-line no-empty-function - // respond: () => {} - // }, - // { - // targets: [member], - // reason: msg.format('I_FILTER_ACTION'), - // duration: action.duration, - // data: { - // filtered: msg.filtered - // } - // } - // ); }