diff --git a/structure/client/components/settings/moderation/ModerationPoints.js b/structure/client/components/settings/moderation/ModerationPoints.js index b01ac7e..18abf97 100644 --- a/structure/client/components/settings/moderation/ModerationPoints.js +++ b/structure/client/components/settings/moderation/ModerationPoints.js @@ -1,5 +1,4 @@ const { Setting } = require('../../../../interfaces/'); -const timestring = require('timestring'); const CONSTANTS = { INFRACTIONS: ['note', 'warn', 'mute', 'unmute', 'lockdown', 'unlockdown', 'kick', 'ban', 'unban', 'vcmute', 'vcunmute', 'vckick', 'vcban', 'vcunban', 'prune', 'slowmode', 'dehoist', 'addrole', 'removerole', 'nickname'] @@ -62,20 +61,21 @@ class ModerationPointsSetting extends Setting { index = null, langParams = {}; method = method.toLowerCase(); + const { resolver } = this.client; - if (this.client.resolver.resolveBoolean(method)) { + if (resolver.resolveBoolean(method)) { setting.enabled = true; index = 'S_MODPOINTS_TOGGLE'; langParams = { toggle: message.format('ON_OFF_TOGGLE', { toggle: true }, true) }; - } else if (this.client.resolver.resolveBoolean(method) === false) { + } else if (resolver.resolveBoolean(method) === false) { setting.enabled = false; index = 'S_MODPOINTS_TOGGLE'; langParams = { toggle: message.format('ON_OFF_TOGGLE', { toggle: false }, true) }; } else if (method === 'multiplier') { const [bool] = params; - if (this.client.resolver.resolveBoolean(bool)) setting.multiplier = true; - else if (this.client.resolver.resolveBooeal(bool) === false) setting.multiplier = false; + if (resolver.resolveBoolean(bool)) setting.multiplier = true; + else if (resolver.resolveBooeal(bool) === false) setting.multiplier = false; else return { error: true, msg: message.format('ERR_INVALID_SUBMETHOD', { submethod: bool }) @@ -83,7 +83,7 @@ class ModerationPointsSetting extends Setting { } else if (method === 'associate') { - const { method: submethod, changed } = await this.client.resolver.resolveMethod(params, null, Object.keys(setting.associations)); + const { method: submethod, changed } = await resolver.resolveMethod(params, null, Object.keys(setting.associations)); if (submethod === 'reset') { setting.associations = {}; @@ -136,12 +136,7 @@ class ModerationPointsSetting extends Setting { if (!timereg.test(content)) return { error: true, msg: message.format('S_MODPOINTS_INVALID_TIMESTRING') }; const match = content.match(timereg); - let time = null; - try { - time = timestring(match[1]); - } catch (e) { - //Do nothing - } + const time = resolver.resolveTime(match[1]); if (time === null) return { error: true, msg: message.format('S_MODPOINTS_INVALID_TIMESTRING') }; @@ -173,11 +168,11 @@ class ModerationPointsSetting extends Setting { inline: false }, { name: '》Points', - value: Object.keys(setting.points).map(key => `\`${key}: ${setting.points[key]}\``).join(', '), + value: Object.keys(setting.points).map((key) => `\`${key}: ${setting.points[key]}\``).join(', '), inline: false }, { name: '》Expirations', - value: Object.keys(setting.expirations).map(key => `\`${key}: ${setting.expirations[key] ? this.client.resolver.timeAgo(setting.expirations[key]): 'Never'}\``).join(', '), + value: Object.keys(setting.expirations).map((key) => `\`${key}: ${setting.expirations[key] ? this.client.resolver.timeAgo(setting.expirations[key]): 'Never'}\``).join(', '), inline: false } ];