From 7586a33dcd6597f55ccd4b183a6c2c446dd22372 Mon Sep 17 00:00:00 2001 From: Navy Date: Mon, 10 May 2021 14:59:36 +0300 Subject: [PATCH] fix issue with being unable to reset list --- .../settings/moderation/WordFilter.js | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/structure/client/components/settings/moderation/WordFilter.js b/structure/client/components/settings/moderation/WordFilter.js index 697831b..9b5a24b 100644 --- a/structure/client/components/settings/moderation/WordFilter.js +++ b/structure/client/components/settings/moderation/WordFilter.js @@ -77,10 +77,6 @@ module.exports = class WordFilter extends FilterSetting { } else if (['explicit', 'fuzzy', 'regex', 'whitelist'].includes(method)) { - if (args.length < 2) return { - error: true, - msg: message.format('MISSING_ARGS') - }; if (method === 'regex') args = args.map((arg) => Util.sanitiseRegex(arg)); const resolved = await resolver.resolveMethod(args, { existing: setting[method], @@ -90,16 +86,17 @@ module.exports = class WordFilter extends FilterSetting { error: true, msg: message.format('ERR_INVALID_METHOD', { method: resolved.method || args[0] }) }; + else if (args.length < 2 && resolved.method !== 'reset') return { + error: true, + msg: message.format('MISSING_ARGS') + }; + setting[method] = resolved.result || []; index = resolved.changed.length ? 'S_WORDFILTER_' + method.toUpperCase() + '_' + resolved.method.toUpperCase() : 'S_NO_CHANGE'; langParams = { changed: resolved.changed.join('`, `') || '' }; } else if (['ignore', 'channelignore', 'ignorechannel'].includes(method)) { - if (args.length < 2) return { - error: true, - msg: message.format('MISSING_ARGS') - }; const resolved = await resolver.resolveMethod(args, { existing: setting.ignore, resolver: resolver.resolveChannels.bind(resolver), @@ -110,16 +107,17 @@ module.exports = class WordFilter extends FilterSetting { error: true, msg: message.format('ERR_INVALID_METHOD', { method: args[0] }) }; + else if (args.length < 2 && resolved.method !== 'reset') return { + error: true, + msg: message.format('MISSING_ARGS') + }; + index = 'S_WORDFILTER_IGNORE_' + resolved.method.toUpperCase(); langParams.changed = resolved.resolved.join(', '); //.filter((ch) => !setting.ignore.includes(ch.id)) setting.ignore = resolved.result; } else if (['bypass', 'roleignore', 'ignorerole'].includes(method)) { - if (args.length < 2) return { - error: true, - msg: message.format('MISSING_ARGS') - }; const resolved = await resolver.resolveMethod(args, { existing: setting.bypass, resolver: resolver.resolveRoles.bind(resolver), @@ -130,6 +128,11 @@ module.exports = class WordFilter extends FilterSetting { error: true, msg: message.format('ERR_INVALID_METHOD', { method: args[0] }) }; + else if (args.length < 2 && resolved.method !== 'reset') return { + error: true, + msg: message.format('MISSING_ARGS') + }; + index = 'S_WORDFILTER_BYPASS_' + resolved.method.toUpperCase(); langParams.changed = resolved.resolved.map((role) => role.name).join(', '); // .filter((ch) => !setting.bypass.includes(ch.id)) setting.bypass = resolved.result;