forked from Galactic/galactic-bot
various fixes
This commit is contained in:
parent
7613f650c7
commit
3b66549686
@ -1,5 +1,4 @@
|
|||||||
const { Setting } = require('../../../../interfaces/');
|
const { Setting } = require('../../../../interfaces/');
|
||||||
const timestring = require('timestring');
|
|
||||||
|
|
||||||
const CONSTANTS = {
|
const CONSTANTS = {
|
||||||
INFRACTIONS: ['note', 'warn', 'mute', 'unmute', 'lockdown', 'unlockdown', 'kick', 'ban', 'unban', 'vcmute', 'vcunmute', 'vckick', 'vcban', 'vcunban', 'prune', 'slowmode', 'dehoist', 'addrole', 'removerole', 'nickname']
|
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,
|
index = null,
|
||||||
langParams = {};
|
langParams = {};
|
||||||
method = method.toLowerCase();
|
method = method.toLowerCase();
|
||||||
|
const { resolver } = this.client;
|
||||||
|
|
||||||
if (this.client.resolver.resolveBoolean(method)) {
|
if (resolver.resolveBoolean(method)) {
|
||||||
setting.enabled = true;
|
setting.enabled = true;
|
||||||
index = 'S_MODPOINTS_TOGGLE';
|
index = 'S_MODPOINTS_TOGGLE';
|
||||||
langParams = { toggle: message.format('ON_OFF_TOGGLE', { toggle: true }, true) };
|
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;
|
setting.enabled = false;
|
||||||
index = 'S_MODPOINTS_TOGGLE';
|
index = 'S_MODPOINTS_TOGGLE';
|
||||||
langParams = { toggle: message.format('ON_OFF_TOGGLE', { toggle: false }, true) };
|
langParams = { toggle: message.format('ON_OFF_TOGGLE', { toggle: false }, true) };
|
||||||
} else if (method === 'multiplier') {
|
} else if (method === 'multiplier') {
|
||||||
|
|
||||||
const [bool] = params;
|
const [bool] = params;
|
||||||
if (this.client.resolver.resolveBoolean(bool)) setting.multiplier = true;
|
if (resolver.resolveBoolean(bool)) setting.multiplier = true;
|
||||||
else if (this.client.resolver.resolveBooeal(bool) === false) setting.multiplier = false;
|
else if (resolver.resolveBooeal(bool) === false) setting.multiplier = false;
|
||||||
else return {
|
else return {
|
||||||
error: true,
|
error: true,
|
||||||
msg: message.format('ERR_INVALID_SUBMETHOD', { submethod: bool })
|
msg: message.format('ERR_INVALID_SUBMETHOD', { submethod: bool })
|
||||||
@ -83,7 +83,7 @@ class ModerationPointsSetting extends Setting {
|
|||||||
|
|
||||||
} else if (method === 'associate') {
|
} 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') {
|
if (submethod === 'reset') {
|
||||||
setting.associations = {};
|
setting.associations = {};
|
||||||
@ -136,12 +136,7 @@ class ModerationPointsSetting extends Setting {
|
|||||||
if (!timereg.test(content)) return { error: true, msg: message.format('S_MODPOINTS_INVALID_TIMESTRING') };
|
if (!timereg.test(content)) return { error: true, msg: message.format('S_MODPOINTS_INVALID_TIMESTRING') };
|
||||||
|
|
||||||
const match = content.match(timereg);
|
const match = content.match(timereg);
|
||||||
let time = null;
|
const time = resolver.resolveTime(match[1]);
|
||||||
try {
|
|
||||||
time = timestring(match[1]);
|
|
||||||
} catch (e) {
|
|
||||||
//Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
if (time === null) return { error: true, msg: message.format('S_MODPOINTS_INVALID_TIMESTRING') };
|
if (time === null) return { error: true, msg: message.format('S_MODPOINTS_INVALID_TIMESTRING') };
|
||||||
|
|
||||||
@ -173,11 +168,11 @@ class ModerationPointsSetting extends Setting {
|
|||||||
inline: false
|
inline: false
|
||||||
}, {
|
}, {
|
||||||
name: '》Points',
|
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
|
inline: false
|
||||||
}, {
|
}, {
|
||||||
name: '》Expirations',
|
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
|
inline: false
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user