forked from Galactic/galactic-bot
fix bug with whitelist checking and error loggin
This commit is contained in:
parent
269bd70070
commit
29964f3a53
@ -111,7 +111,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
try { // NOTE: Remove try-catch after debug
|
try { // NOTE: Remove try-catch after debug
|
||||||
content = FilterUtil.normalise(Util.removeMarkdown(msg.cleanContent));
|
content = FilterUtil.normalise(Util.removeMarkdown(msg.cleanContent));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.client.logger.debug(log);
|
this.client.logger.error(`Error in message filtering:\n${err.stack}\n${msg.cleanContent}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log += `\nNormalised: ${content}`;
|
log += `\nNormalised: ${content}`;
|
||||||
@ -182,7 +182,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
|
|
||||||
for (const reg of regex) {
|
for (const reg of regex) {
|
||||||
|
|
||||||
const match = content.match(new RegExp(`(?:^|\\s)(${reg})`, 'iu')); // (?:^|\\s) |un
|
const match = content.toLowerCase().match(new RegExp(`(?:^|\\s)(${reg})`, 'iu')); // (?:^|\\s) |un
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
//log += `\next reg: ${tmp}`;
|
//log += `\next reg: ${tmp}`;
|
||||||
@ -192,7 +192,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
try { // This is for debugging only
|
try { // This is for debugging only
|
||||||
inWL = this.whitelist.find(fullWord);
|
inWL = this.whitelist.find(fullWord);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.client.logger.debug(fullWord, match[0], words);
|
this.client.logger.debug(fullWord, match[1], words);
|
||||||
}
|
}
|
||||||
if (inWL || whitelist.some((word) => word === fullWord)) continue;
|
if (inWL || whitelist.some((word) => word === fullWord)) continue;
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
filterResult = {
|
filterResult = {
|
||||||
match: fullWord,
|
match: fullWord,
|
||||||
matched: true,
|
matched: true,
|
||||||
_matcher: match[0].toLowerCase(),
|
_matcher: match[1].toLowerCase(),
|
||||||
matcher: `Regex: __${reg}__`,
|
matcher: `Regex: __${reg}__`,
|
||||||
type: 'regex'
|
type: 'regex'
|
||||||
};
|
};
|
||||||
@ -316,7 +316,13 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
const logChannel = await guild.resolveChannel(_logChannel);
|
const logChannel = await guild.resolveChannel(_logChannel);
|
||||||
const msg = edited || message;
|
const msg = edited || message;
|
||||||
if (!msg.content) return;
|
if (!msg.content) return;
|
||||||
const content = FilterUtil.normalise(msg.cleanContent);
|
let content = null;
|
||||||
|
try {
|
||||||
|
content = FilterUtil.normalise(msg.cleanContent);
|
||||||
|
} catch (err) {
|
||||||
|
this.client.logger.error(`Error in message flag:\n${err.stack}\n${msg.cleanContent}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
let match = null;
|
let match = null;
|
||||||
|
|
||||||
for (const reg of words) {
|
for (const reg of words) {
|
||||||
|
Loading…
Reference in New Issue
Block a user