diff --git a/structure/client/components/settings/moderation/WordFilter.js b/structure/client/components/settings/moderation/WordFilter.js index dc0f709..eece9f7 100644 --- a/structure/client/components/settings/moderation/WordFilter.js +++ b/structure/client/components/settings/moderation/WordFilter.js @@ -145,7 +145,7 @@ module.exports = class WordFilter extends FilterSetting { const submethod = args.shift().toLowerCase(); const resolved = await resolver.resolveMethod([submethod], null, null, { - allowedMethods: ['add', 'remove', 'edit', 'list'] + allowedMethods: ['add', 'remove', 'edit', 'list', 'reset'] }); if (!resolved) return { error: true, msg: message.format('ERR_INVALID_METHOD', { method: submethod }) }; @@ -162,6 +162,10 @@ module.exports = class WordFilter extends FilterSetting { } else if (resolved.method === 'list') { this._listActions(message, setting); return; + } else if (resolved.method === 'reset') { + result = {}; + setting.actions = []; + index = 'S_FILTER_ACTION_RESET'; } if (result.error) return result; @@ -174,7 +178,7 @@ module.exports = class WordFilter extends FilterSetting { points: result.points || message.format('ON_OFF_TOGGLE', { toggle: false }, true), force: message.format('ON_OFF_TOGGLE', { toggle: result.force }, true), prune: message.format('ON_OFF_TOGGLE', { toggle: result.prune }, true), - trigger: result.trigger instanceof Array ? '||' + result.trigger.join(', ') + '||' : result.trigger + trigger: result.trigger instanceof Array ? '||' + result.trigger.join(', ') + '||' : '`' + result.trigger + '`' }; } @@ -190,6 +194,10 @@ module.exports = class WordFilter extends FilterSetting { async _createTrigger(message, action, actionObject, setting) { const response = await message.prompt(message.format('S_WORDFILTER_ACTION_ADD_TRIGGERS'), { time: 60 * 1000 }); if (!response) { + if (setting.actions.find((ac) => ac.trigger === 'generic')) return { + error: true, + msg: message.format('S_FILTER_ACTIONS_EXISTING', { trigger: 'generic' }) + }; setting.actions.push(actionObject); actionObject.trigger = 'generic'; return actionObject; @@ -216,7 +224,7 @@ module.exports = class WordFilter extends FilterSetting { const { actions } = setting; const words = params.map((word) => word.toLowerCase()); const removed = []; - for (const word of words) { + for (const word of [...words]) { const existing = actions.find((ac) => ac.trigger.includes(word)); if (!existing) continue; words.splice(words.indexOf(word), 1);