forked from Galactic/galactic-bot
cleanup
This commit is contained in:
parent
b7d5d09118
commit
baba22c5ae
@ -48,9 +48,9 @@ module.exports = class AutoModeration extends Observer {
|
||||
|
||||
}
|
||||
|
||||
async _moderate(action, guild, channel, member, removeme2, silent, reason, filterResult, removeme) {
|
||||
async _moderate(action, guild, channel, member, reason, filterResult) {
|
||||
const InfractionClass = CONSTANTS.Infractions[action.type];
|
||||
await this.client.moderationManager._handleTarget(InfractionClass, member, {
|
||||
const result = await this.client.moderationManager._handleTarget(InfractionClass, member, {
|
||||
guild,
|
||||
channel,
|
||||
executor: guild.me,
|
||||
@ -61,50 +61,10 @@ module.exports = class AutoModeration extends Observer {
|
||||
silent: true,
|
||||
force: false,
|
||||
data: {
|
||||
automoderation: {
|
||||
type: 'filler',
|
||||
matched: {
|
||||
type: 'wordfiltertype/explicit/regex/whatever',
|
||||
word: 'whatwasmatched'
|
||||
}
|
||||
|
||||
}
|
||||
automoderation: filterResult
|
||||
}
|
||||
});
|
||||
|
||||
// this.client.moderationManager.autoModerate({ guild, action, message, reason, silent, data: { filterResult } });
|
||||
|
||||
/* 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
|
||||
},
|
||||
format: guild.format.bind(guild),
|
||||
// eslint-disable-next-line no-empty-function
|
||||
respond: () => { }
|
||||
},
|
||||
{
|
||||
targets: [member],
|
||||
reason,
|
||||
duration: action.duration,
|
||||
data: {
|
||||
filterResult
|
||||
}
|
||||
}
|
||||
);*/
|
||||
}
|
||||
|
||||
async filterWords(message, edited) {
|
||||
@ -114,7 +74,7 @@ module.exports = class AutoModeration extends Observer {
|
||||
|
||||
const member = message.member || await guild.members.fetch(author.id).catch();
|
||||
const settings = await guild.settings();
|
||||
const { wordFilter: setting, moderationPoints } = settings;
|
||||
const { wordFilter: setting } = settings;
|
||||
const { bypass, ignore, enabled, silent, explicit, fuzzy, regex, whitelist, actions } = setting;
|
||||
const roles = member?.roles.cache.map((r) => r.id) || [];
|
||||
|
||||
@ -143,34 +103,11 @@ module.exports = class AutoModeration extends Observer {
|
||||
// matcher: what gets shown in the message logs |
|
||||
// _matcher: locally used variable for which word in the list triggered it |
|
||||
// type: which detection type matched it
|
||||
let filterResult = { match: null, matched: false, matcher: null, _matcher: null, preset: false };
|
||||
let filterResult = { filter: 'word', match: null, matched: false, matcher: null, _matcher: null, preset: false };
|
||||
const words = content.toLowerCase().split(' ').filter((elem) => elem.length);
|
||||
// Remove any potential bypass characters
|
||||
//const _words = words.map((word) => word.replace(/[.'*_?+"#%&=-]/gu, ''));
|
||||
|
||||
// 1. Filter for preset lists
|
||||
// CHANGED BEHAVIOUR OF PRESETS, THEY NOW USE THE REGEX PART OF THE FILTER
|
||||
// if (presets.length) {
|
||||
// for (const preset of presets) {
|
||||
|
||||
// const text = _words.join('').replace(/\s/u, ''); //Also check for spaced out words, ex "f u c k"
|
||||
// //Combine array of presets to one expression
|
||||
// const _regex = new RegExp(`(${FilterPresets[preset].join(')|(')})`, 'ui');
|
||||
// const match = content.match(_regex) || text.length === words.length ? text.match(_regex) : null;
|
||||
// if (!match) continue;
|
||||
// this.client.logger.debug(`\nMessage matched with "${preset}" preset list.\nMatch: ${match[0]}\nFull content: ${content}`);
|
||||
// filterResult = {
|
||||
// match: match[0],
|
||||
// matched: true,
|
||||
// matcher: preset,
|
||||
// preset,
|
||||
// type: 'preset'
|
||||
// };
|
||||
// break;
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// 2. Filter explicit - no bypass checking (unless you count normalising the text, i.e. emoji letters => normal letters)
|
||||
if (explicit.length && !filterResult.matched) {
|
||||
|
||||
@ -308,8 +245,8 @@ module.exports = class AutoModeration extends Observer {
|
||||
this.client.rateLimiter.queueDelete(msg.channel, msg).catch(catcher(279));
|
||||
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);
|
||||
filterResult.filter = 'word';
|
||||
this._moderate(action, guild, channel, member, msg.format('W_FILTER_ACTION'), filterResult, message);
|
||||
|
||||
} else {
|
||||
this.client.rateLimiter.queueDelete(msg.channel, msg).catch(catcher(286));
|
||||
@ -456,7 +393,7 @@ module.exports = class AutoModeration extends Observer {
|
||||
this.client.rateLimiter.queueDelete(msg.channel, msg);
|
||||
//msg.delete();
|
||||
|
||||
this._moderate(action, guild, channel, member, moderationPoints, silent, msg.format('L_FILTER_ACTION'), filterResult, message);
|
||||
this._moderate(action, guild, channel, member, msg.format('L_FILTER_ACTION'), filterResult, message);
|
||||
|
||||
} else this.client.rateLimiter.queueDelete(msg.channel, msg); //msg.delete();
|
||||
|
||||
@ -469,7 +406,7 @@ module.exports = class AutoModeration extends Observer {
|
||||
|
||||
const member = message.member || await guild.members.fetch(author.id).catch();
|
||||
const settings = await guild.settings();
|
||||
const { inviteFilter: setting, moderationPoints } = settings;
|
||||
const { inviteFilter: setting } = settings;
|
||||
const { bypass, ignore, actions, silent, enabled } = setting;
|
||||
if (!enabled) return;
|
||||
const roles = member?.roles.cache.map((r) => r.id) || [];
|
||||
@ -502,7 +439,7 @@ module.exports = class AutoModeration extends Observer {
|
||||
msg.filtered.sactioned = true;
|
||||
this.client.rateLimiter.queueDelete(msg.channel, msg);
|
||||
|
||||
this._moderate(action, guild, channel, member, moderationPoints, silent, msg.format('I_FILTER_ACTION'), { filtered: msg.filtered }, message);
|
||||
this._moderate(action, guild, channel, member, msg.format('I_FILTER_ACTION'), { filtered: msg.filtered }, message);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user