diff --git a/commands/System/conf.js b/commands/System/conf.js index 9121a3f9..4e9760cb 100644 --- a/commands/System/conf.js +++ b/commands/System/conf.js @@ -1,5 +1,14 @@ exports.run = (client, msg, [action, key, ... value]) => { - value = value.join(" "); + + if (msg.guildConf[key].constructor.name === "String") { + value = value.join(' '); + } else + if (msg.guildConf[key].constructor.name === "Boolean") { + value = value[0]; + } else { + value = value; + } + if(action === "list") { msg.channel.sendCode("json", require("util").inspect(msg.guildConf)); return; @@ -12,7 +21,7 @@ exports.run = (client, msg, [action, key, ... value]) => { } else if(action === "set") { - if(!key || !value) return msg.reply("Please provide both a key and value!"); + if(!key || value === undefined) return msg.reply("Please provide both a key and value!"); client.funcs.confs.set(msg.guild, key, value); return msg.reply(`The value for ${key} has been set to: ${value}`); } else @@ -36,6 +45,6 @@ exports.conf = { exports.help = { name: "conf", description: "Define per-server configuration.", - usage: " [key:str] [channel:channel|user:user|role:role|int:int|str:str]", + usage: " [key:str] [boolean:boolean|channel:channel|user:user|role:role|int:int|str:str]", usageDelim: " " }; diff --git a/inhibitors/disable.js b/inhibitors/disable.js index 3c36c5d2..73f7ae95 100644 --- a/inhibitors/disable.js +++ b/inhibitors/disable.js @@ -5,7 +5,7 @@ exports.conf = { exports.run = (client, msg, cmd) => { return new Promise((resolve, reject) => { - if (cmd.conf.enabled && !msg.guildConf.disabledCommands.includes(cmd)) { + if (cmd.conf.enabled && !msg.guildConf.disabledCommands.includes(cmd.help.name)) { resolve(); } else { reject("This command is currently disabled"); diff --git a/inhibitors/usage.js b/inhibitors/usage.js index a74e2b8d..f79364c4 100644 --- a/inhibitors/usage.js +++ b/inhibitors/usage.js @@ -99,6 +99,19 @@ exports.run = (client, msg, cmd) => { reject(`${currentUsage.possibles[0].name} must be a mention or valid user id.`); } break; + case "boolean": + if (/^true|false$/.test(args[i])) { + if (args[i] === "true") + args[i] = true; + else args[i] = false; + validateArgs(++i); + } else if (currentUsage.type === "optional" && !repeat) { + args.splice(i, 0, undefined); + validateArgs(++i); + } else { + reject(`${currentUsage.possibles[0].name} must be true or false.`) + } + break; case "member": if (/^<@!?\d+>$/.test(args[i]) && msg.guild.members.has(/\d+/.exec(args[i])[0]) && args[i].length > 5) { args[i] = msg.guild.members.get(/\d+/.exec(args[i])[0]); @@ -374,6 +387,16 @@ exports.run = (client, msg, cmd) => { multiPossibles(++p); } break; + case "boolean": + if (/^true|false$/.test(args[i])) { + if (args[i] === "true") args[i] = true; + else args[i] = false; + validated = true; + multiPossibles(++p); + } else { + multiPossibles(++p); + } + break; case "member": if (result && args[i].length > 5 && msg.guild.members.has(result[0])) { args[i] = msg.guild.members.get(/\d+/.exec(args[i])[0]);