protectiontype alias + resolve for 'roles'

This commit is contained in:
Erik 2021-05-10 23:23:52 +03:00
parent 329811a661
commit 536d234c40
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16

View File

@ -8,6 +8,9 @@ class ProtectionSetting extends Setting {
name: 'protection',
module: 'administration',
usage: "<'type'|'add'|'remove'> <'role'|'position'|role..>",
aliases: [
'protectiontype'
],
examples: [
'protection type <role|position>',
'protection add <role..>',
@ -36,15 +39,16 @@ class ProtectionSetting extends Setting {
const langParams = {};
if (method === 'type') {
if (method === 'type' || message._caller === 'protectiontype') {
if (!params[1]) return {
error: true,
msg: message.format('MISSING_ARGS')
};
const value = params[1].toLowerCase();
if (!['role', 'position'].includes(value)) return { error: true, msg: message.format('S_PROTECTION_INVALID_ARGS') };
let value = params[1].toLowerCase();
if (!['role', 'roles', 'position'].includes(value)) return { error: true, msg: message.format('S_PROTECTION_INVALID_ARGS') };
if (value === 'roles') value = 'role';
setting.type = value;
index = 'S_PROTECTION_TYPE';