From 3b55561b89ad568332318b885a3e4183a43c055f Mon Sep 17 00:00:00 2001 From: Navy Date: Wed, 9 Jun 2021 14:33:46 +0300 Subject: [PATCH] brrrrrrrrrrrrrrrrrrr --- Manager.js | 2 +- structure/client/components/settings/moderation/WordFilter.js | 2 +- util/Util.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Manager.js b/Manager.js index 105b388..8190504 100644 --- a/Manager.js +++ b/Manager.js @@ -41,7 +41,7 @@ class Manager extends EventEmitter { await this.shardManager.spawn(); // G:\Documents\My programs\GBot\New GBot\api\index.cjs this.info('Shards done, booting up API...'); - const API = await import('./api/index.js').catch((err) => this.error(`Import of API Manager failed.\n${err.stack}`)); + const API = await import('./api/index.js').catch(() => this.warn(`Import of API Manager failed. Skipping API.`)); if (API) { const { default: APIManager } = API; this.apiManager = new APIManager(this); diff --git a/structure/client/components/settings/moderation/WordFilter.js b/structure/client/components/settings/moderation/WordFilter.js index e274a24..7b2da00 100644 --- a/structure/client/components/settings/moderation/WordFilter.js +++ b/structure/client/components/settings/moderation/WordFilter.js @@ -78,7 +78,7 @@ module.exports = class WordFilter extends FilterSetting { } else if (['explicit', 'fuzzy', 'regex', 'whitelist'].includes(method)) { const [first, ...rest] = args; // First arg should skip sanitisation - if (method === 'regex') args = rest.map((arg) => Util.sanitiseRegex(arg)); + if (method === 'regex') args = rest.map((arg) => Util.sanitiseRegex(arg, ['?', '\\', '(', ')', '|', '\\[', '\\]', '.', '-'])); const resolved = await resolver.resolveMethod([first, ...args], { existing: setting[method], allowedMethods: ['add', 'remove', 'set', 'reset'] diff --git a/util/Util.js b/util/Util.js index e8f3367..819a17a 100644 --- a/util/Util.js +++ b/util/Util.js @@ -124,11 +124,11 @@ class Util { * * @static * @param {string} input - * @param {string} [allowed=['?', '\\', '(', ')', '|']] + * @param {string[]} [allowed=['?', '\\', '(', ')', '|']] * @return {string} The sanitised expression * @memberof Util */ - static sanitiseRegex(input, allowed = ['?', '\\', '(', ')', '|', '\\[', '\\]', '.']) { + static sanitiseRegex(input, allowed = ['?', '\\', '(', ')', '|']) { if (!input) throw new Error('Missing input'); const reg = new RegExp(`[${this.regChars.filter((char) => !allowed.includes(char)).join('')}]`, 'gu'); return input.replace(reg, '\\$&');