fix issue with being unable to reset list

This commit is contained in:
Erik 2021-05-10 14:59:36 +03:00
parent 99e5cde911
commit 7586a33dcd
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16

View File

@ -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;