From e261debb6956d4ef8c2612af941292d3ce1f1719 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 13 Jul 2022 11:42:17 +0300 Subject: [PATCH] improve linkfilter --- src/structure/components/observers/Automoderation.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/structure/components/observers/Automoderation.js b/src/structure/components/observers/Automoderation.js index 2376a89..19b8c52 100644 --- a/src/structure/components/observers/Automoderation.js +++ b/src/structure/components/observers/Automoderation.js @@ -441,7 +441,12 @@ module.exports = class AutoModeration extends Observer { if (!msg.content) return; const content = msg.content.split('').join(''); //Copy the string... let matches = content.match(this.regex.linkRegG); - if (!matches) matches = content.replace(/\s/u, '').match(this.regex.linkRegG); + let removedWhitespace = false; + if (!matches) { + matches = content.replace(/\s/u, '').match(this.regex.linkRegG); + removedWhitespace = true; + } + if (!matches) return; let remove = false; const filterResult = {}; @@ -480,6 +485,9 @@ module.exports = class AutoModeration extends Observer { // console.log(parts, validTld); if (!validTld) continue; const valid = await resolver.validateDomain(domain); + + if (removedWhitespace && !match.includes(`${domain}/`)) continue; + if (!valid) { if (match.includes(`${domain}/`)) this.client.emit('linkFilterWarn', { guild: wrapper, message: wrapper.format('LINKFILTER_WARN', { domain, link: match }) }); continue;