From ad48002c691ef0c091f74988076e8ea9bdfa2d18 Mon Sep 17 00:00:00 2001 From: Faith Date: Sat, 29 Oct 2016 09:16:58 -0400 Subject: [PATCH] Custom Permission Roles Support --- functions/confs.js | 5 ++++- functions/permissionLevel.js | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/functions/confs.js b/functions/confs.js index ded95b4d..583a0478 100644 --- a/functions/confs.js +++ b/functions/confs.js @@ -11,7 +11,9 @@ exports.init = (client) => { // Load default configuration, create if not exist. defaultConf = { prefix: {type: "String", data: client.config.prefix}, - disabledCommands: {type: "Array", data: "[]"} + disabledCommands: {type: "Array", data: []}, + mod_role: {type: "String", data: "Mods"}, + admin_role: {type: "String", data: "Devs"} }; fs.ensureFileSync(dataDir + path.sep + defaultFile); @@ -140,6 +142,7 @@ exports.set = (guild, key, value) => { } thisConf[key] = {data : value , type : defaultConf[key].type}; + guildConfs.set(guild.id, thisConf); fs.outputJSONSync(path.resolve(dataDir + path.sep + guild.id + ".json"), thisConf); diff --git a/functions/permissionLevel.js b/functions/permissionLevel.js index f01a0421..e08ae418 100644 --- a/functions/permissionLevel.js +++ b/functions/permissionLevel.js @@ -1,13 +1,14 @@ module.exports = (client, user, guild = null) => { return new Promise((resolve, reject) => { + let guildConf = client.funcs.confs.get(guild); let permlvl = 0; if(guild) { - try{ + try { let member = guild.member(user); - let mod_role = guild.roles.find("name", "Mods"); + let mod_role = guild.roles.find("name", guildConf.mod_role); if (mod_role && member.roles.has(mod_role.id)) permlvl = 2; - let admin_role = guild.roles.find("name", "Devs"); + let admin_role = guild.roles.find("name", guildConf.admin_role); if (admin_role && member.roles.has(admin_role.id)) permlvl = 3; if(member === guild.owner)