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

Custom Permission Roles Support #57

Merged
merged 1 commit into from
Oct 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hard coding Mods and Devs to be default

Why not default them as blank values?

admin_role: {type: "String", data: "Devs"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with Line 16

};

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also like please use camelCase for modRole

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here

if (admin_role && member.roles.has(admin_role.id))
permlvl = 3;
if(member === guild.owner)
Expand Down