Skip to content
This repository has been archived by the owner on Aug 27, 2018. It is now read-only.

Commit

Permalink
Merge pull request #62 from UnseenFaith/faith-patch-3
Browse files Browse the repository at this point in the history
Fix for Conf Command
  • Loading branch information
eslachance authored Nov 1, 2016
2 parents 35f50d9 + f32faec commit f059389
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
15 changes: 12 additions & 3 deletions commands/System/conf.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -36,6 +45,6 @@ exports.conf = {
exports.help = {
name: "conf",
description: "Define per-server configuration.",
usage: "<set|get|reset|list> [key:str] [channel:channel|user:user|role:role|int:int|str:str]",
usage: "<set|get|reset|list> [key:str] [boolean:boolean|channel:channel|user:user|role:role|int:int|str:str]",
usageDelim: " "
};
2 changes: 1 addition & 1 deletion inhibitors/disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
23 changes: 23 additions & 0 deletions inhibitors/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit f059389

Please sign in to comment.