forked from Galactic/galactic-bot
check if a message is already filtered
This commit is contained in:
parent
287193dd17
commit
a60e6728fd
@ -122,7 +122,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
async filterWords(message, edited) {
|
async filterWords(message, edited) {
|
||||||
|
|
||||||
const { guild, author, channel, guildWrapper: wrapper } = 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 member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
||||||
const settings = await wrapper.settings();
|
const settings = await wrapper.settings();
|
||||||
@ -419,7 +419,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
async filterLinks(message, edited) {
|
async filterLinks(message, edited) {
|
||||||
|
|
||||||
const { guild, author, channel, guildWrapper: wrapper } = 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 member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
||||||
const { resolver } = this.client;
|
const { resolver } = this.client;
|
||||||
@ -449,10 +449,12 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
|
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
const { domain } = match.match(this.regex.linkReg).groups;
|
const { domain } = match.match(this.regex.linkReg).groups;
|
||||||
|
// Invites are filtered separately
|
||||||
|
if (domain.toLowerCase() === 'discord.gg') continue;
|
||||||
log += `\nMatched link ${match}: `;
|
log += `\nMatched link ${match}: `;
|
||||||
|
|
||||||
const predicate = (dom) => {
|
const predicate = (dom) => {
|
||||||
return dom.includes(domain) || domain.includes(dom);
|
return dom.toLowerCase().includes(domain) || domain.includes(dom.toLowerCase());
|
||||||
};
|
};
|
||||||
|
|
||||||
if (blacklist.some(predicate)) {
|
if (blacklist.some(predicate)) {
|
||||||
@ -506,7 +508,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.rateLimiter.queueDelete(msg.channel, msg);
|
this.client.rateLimiter.queueDelete(msg.channel, msg).catch(() => null);
|
||||||
|
|
||||||
if (actions.length) {
|
if (actions.length) {
|
||||||
|
|
||||||
@ -534,7 +536,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
async filterInvites(message, edited) {
|
async filterInvites(message, edited) {
|
||||||
|
|
||||||
const { guild, author, channel, guildWrapper: wrapper } = 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 member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
||||||
const settings = await wrapper.settings();
|
const settings = await wrapper.settings();
|
||||||
@ -561,7 +563,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
const result = await wrapper.checkInvite(match.groups.code);
|
const result = await wrapper.checkInvite(match.groups.code);
|
||||||
const invite = await this.client.fetchInvite(match.groups.code);
|
const invite = await this.client.fetchInvite(match.groups.code);
|
||||||
if (whitelist.includes(invite.guild.id)) return;
|
if (whitelist.includes(invite.guild.id)) return;
|
||||||
|
|
||||||
if (!result) { // Doesn't resolve to the origin server
|
if (!result) { // Doesn't resolve to the origin server
|
||||||
|
|
||||||
let action = null;
|
let action = null;
|
||||||
@ -572,7 +574,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
matcher: 'invites',
|
matcher: 'invites',
|
||||||
filter: 'invite'
|
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) {
|
if (!silent) {
|
||||||
const res = await this.client.rateLimiter.limitSend(msg.channel, wrapper.format('I_FILTER_DELETE', { user: author.id }), undefined, 'inviteFilter');
|
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 });
|
//if (res) res.delete({ timeout: 10000 });
|
||||||
@ -592,7 +594,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
async filterMentions(message) {
|
async filterMentions(message) {
|
||||||
|
|
||||||
const { guild, author, channel, guildWrapper: wrapper } = 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 member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
||||||
const settings = await wrapper.settings();
|
const settings = await wrapper.settings();
|
||||||
@ -629,7 +631,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.rateLimiter.queueDelete(channel, message);
|
this.client.rateLimiter.queueDelete(channel, message).catch(() => null);
|
||||||
const filterResult = {
|
const filterResult = {
|
||||||
filter: 'mention',
|
filter: 'mention',
|
||||||
amount: ids.length
|
amount: ids.length
|
||||||
|
Loading…
Reference in New Issue
Block a user