From b66a126c56521613007c00f0b9ac83a63b2492a6 Mon Sep 17 00:00:00 2001 From: Faith Date: Mon, 31 Oct 2016 00:46:51 -0400 Subject: [PATCH 1/4] Fix for Core 'conf' command --- commands/System/conf.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/System/conf.js b/commands/System/conf.js index 9121a3f9..adb0aace 100644 --- a/commands/System/conf.js +++ b/commands/System/conf.js @@ -13,6 +13,10 @@ exports.run = (client, msg, [action, key, ... value]) => { if(action === "set") { if(!key || !value) return msg.reply("Please provide both a key and value!"); + if (value === "true") + value = true; + if (value === "false") + value = false; client.funcs.confs.set(msg.guild, key, value); return msg.reply(`The value for ${key} has been set to: ${value}`); } else @@ -36,6 +40,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] [true|false|channel:channel|user:user|role:role|int:int|str:str]", usageDelim: " " }; From ca28d66f0e7ac9b99123183acc108ea0dd09a6ae Mon Sep 17 00:00:00 2001 From: Faith Date: Mon, 31 Oct 2016 05:04:11 -0400 Subject: [PATCH 2/4] Adds Boolean Usage type and reverts old boolean fix --- commands/System/conf.js | 12 +++++------- inhibitors/usage.js | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/commands/System/conf.js b/commands/System/conf.js index adb0aace..a1512d45 100644 --- a/commands/System/conf.js +++ b/commands/System/conf.js @@ -1,5 +1,7 @@ exports.run = (client, msg, [action, key, ... value]) => { - value = value.join(" "); + if (value[1] != undefined) { + value = value.join(' '); + } if(action === "list") { msg.channel.sendCode("json", require("util").inspect(msg.guildConf)); return; @@ -13,11 +15,7 @@ exports.run = (client, msg, [action, key, ... value]) => { if(action === "set") { if(!key || !value) return msg.reply("Please provide both a key and value!"); - if (value === "true") - value = true; - if (value === "false") - value = false; - client.funcs.confs.set(msg.guild, key, value); + client.funcs.confs.set(msg.guild, key, value[1] === undefined ? value[0] : value); return msg.reply(`The value for ${key} has been set to: ${value}`); } else @@ -40,6 +38,6 @@ exports.conf = { exports.help = { name: "conf", description: "Define per-server configuration.", - usage: " [key:str] [true|false|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/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]); From 60e33cd544932dbe1c8c928423de930d388d7f43 Mon Sep 17 00:00:00 2001 From: Faith Date: Mon, 31 Oct 2016 20:46:27 -0400 Subject: [PATCH 3/4] Reverted again and made value checking better. Will now correctly change depending on the type of the key. Set can now set a boolean key as 'false' --- commands/System/conf.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/System/conf.js b/commands/System/conf.js index a1512d45..4e9760cb 100644 --- a/commands/System/conf.js +++ b/commands/System/conf.js @@ -1,7 +1,14 @@ exports.run = (client, msg, [action, key, ... value]) => { - if (value[1] != undefined) { + + 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; @@ -14,8 +21,8 @@ exports.run = (client, msg, [action, key, ... value]) => { } else if(action === "set") { - if(!key || !value) return msg.reply("Please provide both a key and value!"); - client.funcs.confs.set(msg.guild, key, value[1] === undefined ? value[0] : 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 From f32faecb9cfde8ffedc4eb16e5d96a7576cce919 Mon Sep 17 00:00:00 2001 From: Faith Date: Mon, 31 Oct 2016 20:47:37 -0400 Subject: [PATCH 4/4] Quick fix for disable.js not disabling commands in disabledCommands array --- inhibitors/disable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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");