Added setting permissions

You should just do:

permissionObject.manageRoles = true;

for example rather than messing with setBit.
This commit is contained in:
hydrabolt
2015-10-26 12:16:04 +00:00
parent 15f35e8019
commit e9afa94c32
7 changed files with 47 additions and 7 deletions

View File

@@ -59,7 +59,16 @@ var ChannelPermissions = (function () {
return (this.packed >>> x & 1) === 1;
};
ChannelPermissions.prototype.setBit = function setBit() {};
ChannelPermissions.prototype.setBit = function setBit(location, value) {
if (value) {
// allow that permission
this.packed |= 1 << location;
} else {
// not allowed
this.packed &= 1 << location;
}
};
_createClass(ChannelPermissions, [{
key: "createInstantInvite",

View File

@@ -44,7 +44,16 @@ var EvaluatedPermissions = (function () {
return (this.packed >>> x & 1) === 1;
};
EvaluatedPermissions.prototype.setBit = function setBit() {};
EvaluatedPermissions.prototype.setBit = function setBit(location, value) {
if (value) {
// allow that permission
this.packed |= 1 << location;
} else {
// not allowed
this.packed &= 1 << location;
}
};
_createClass(EvaluatedPermissions, [{
key: "createInstantInvite",

View File

@@ -52,10 +52,11 @@ var ServerPermissions = (function () {
if (value) {
// allow that permission
this.packed |= 1 << location;
} else {
// not allowed
}
// not allowed
this.packed &= 1 << location;
}
};
ServerPermissions.prototype.toString = function toString() {