From 570aa63cc677e0d32c7527abce876a22f5929213 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Sun, 15 May 2022 18:18:15 +0400 Subject: [PATCH] Fixed permission handling --- libraries/classes/command-acl.lua | 4 +++- libraries/classes/command.lua | 4 ++-- plugins/security/init.lua | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/classes/command-acl.lua b/libraries/classes/command-acl.lua index 46a46e4..c7e5be2 100644 --- a/libraries/classes/command-acl.lua +++ b/libraries/classes/command-acl.lua @@ -2,6 +2,8 @@ local acl = import("classes.acl") local command_acl = acl:extend("CommandACL") local table_utils = import("table-utils") +local discordia = import("discordia") +local enum_perms = discordia.enums.permission --The following method extends the ACL class to work with rule-specific features, --such as the role position function command_acl:check_group(roles) @@ -34,7 +36,7 @@ end function command_acl:check_perm(perms) local output = true for k,v in pairs(self.perm_rules) do - if not perms[v] then + if (bit.band(perms[1],enum_perms[v]) == 0) then output = false end end diff --git a/libraries/classes/command.lua b/libraries/classes/command.lua index 4c1fe60..a22567b 100644 --- a/libraries/classes/command.lua +++ b/libraries/classes/command.lua @@ -35,8 +35,8 @@ function command:__init(name,callback) self.rules:set_group_rule(k,v) end end - if callback.perm then - self.rules:set_perm_rules(callback.perm) + if callback.perms then + self.rules:set_perm_rules(callback.perms) end if callback.help then self:set_help(callback.help,callback.usage) diff --git a/plugins/security/init.lua b/plugins/security/init.lua index 0585e13..03b1fcf 100644 --- a/plugins/security/init.lua +++ b/plugins/security/init.lua @@ -26,7 +26,7 @@ local grantrole = command("grant-role",{ {name = "Options:",value = "-q - quiet (don't print the result)"} } }}, - perms = { + permss = { "administrator" }, args = { @@ -50,7 +50,7 @@ local revokerole = command("revoke-role",{ {name = "Options:",value = "-q - quiet (don't print the result)"} } }}, - perms = { + permss = { "administrator" }, args = {