mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Added full evaluation of SERVERwide permissions
This commit is contained in:
@@ -9,6 +9,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var User = require("./user.js");
|
||||
var ServerPermissions = require("./ServerPermissions.js");
|
||||
|
||||
var Member = (function (_User) {
|
||||
_inherits(Member, _User);
|
||||
@@ -25,8 +26,9 @@ var Member = (function (_User) {
|
||||
key: "roles",
|
||||
get: function get() {
|
||||
|
||||
var ufRoles = [];
|
||||
var ufRoles = [this.server.getRole(this.server.id)];
|
||||
|
||||
console.log(this.rawRoles);
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
@@ -54,6 +56,43 @@ var Member = (function (_User) {
|
||||
|
||||
return ufRoles;
|
||||
}
|
||||
}, {
|
||||
key: "evalPerms",
|
||||
get: function get() {
|
||||
|
||||
var basePerms = this.roles,
|
||||
//cache roles as it can be slightly expensive
|
||||
basePerm = basePerms[0].packed;
|
||||
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = basePerms[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var perm = _step2.value;
|
||||
|
||||
basePerm = basePerm | perm.packed;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2["return"]) {
|
||||
_iterator2["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ServerPermissions({
|
||||
permissions: basePerm
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Member;
|
||||
|
||||
Reference in New Issue
Block a user