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 #57 from UnseenFaith/faith-patch-1
Browse files Browse the repository at this point in the history
Custom Permission Roles Support
  • Loading branch information
eslachance authored Oct 30, 2016
2 parents 220d4da + ad48002 commit fb9ca6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion functions/confs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 4 additions & 3 deletions functions/permissionLevel.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit fb9ca6c

Please sign in to comment.