check if a message is already filtered

This commit is contained in:
Erik 2022-07-04 18:06:39 +03:00
parent 287193dd17
commit a60e6728fd
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -122,7 +122,7 @@ module.exports = class AutoModeration extends Observer {
async filterWords(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
if (!guild || author.bot) return;
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
const settings = await wrapper.settings();
@ -419,7 +419,7 @@ module.exports = class AutoModeration extends Observer {
async filterLinks(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
if (!guild || author.bot) return;
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
const { resolver } = this.client;
@ -449,10 +449,12 @@ module.exports = class AutoModeration extends Observer {
for (const match of matches) {
const { domain } = match.match(this.regex.linkReg).groups;
// Invites are filtered separately
if (domain.toLowerCase() === 'discord.gg') continue;
log += `\nMatched link ${match}: `;
const predicate = (dom) => {
return dom.includes(domain) || domain.includes(dom);
return dom.toLowerCase().includes(domain) || domain.includes(dom.toLowerCase());
};
if (blacklist.some(predicate)) {
@ -506,7 +508,7 @@ module.exports = class AutoModeration extends Observer {
}, 10000);
}
this.client.rateLimiter.queueDelete(msg.channel, msg);
this.client.rateLimiter.queueDelete(msg.channel, msg).catch(() => null);
if (actions.length) {
@ -534,7 +536,7 @@ module.exports = class AutoModeration extends Observer {
async filterInvites(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
if (!guild || author.bot) return;
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
const settings = await wrapper.settings();
@ -572,7 +574,7 @@ module.exports = class AutoModeration extends Observer {
matcher: 'invites',
filter: 'invite'
};
if (!action) return this.client.rateLimiter.queueDelete(msg.channel, msg); //msg.delete();
if (!action) return this.client.rateLimiter.queueDelete(msg.channel, msg).catch(() => null); //msg.delete();
if (!silent) {
const res = await this.client.rateLimiter.limitSend(msg.channel, wrapper.format('I_FILTER_DELETE', { user: author.id }), undefined, 'inviteFilter');
//if (res) res.delete({ timeout: 10000 });
@ -592,7 +594,7 @@ module.exports = class AutoModeration extends Observer {
async filterMentions(message) {
const { guild, author, channel, guildWrapper: wrapper } = message;
if (!guild || author.bot) return;
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
const settings = await wrapper.settings();
@ -629,7 +631,7 @@ module.exports = class AutoModeration extends Observer {
}, 10000);
}
this.client.rateLimiter.queueDelete(channel, message);
this.client.rateLimiter.queueDelete(channel, message).catch(() => null);
const filterResult = {
filter: 'mention',
amount: ids.length