diff --git a/lib/ChannelPermissions.js b/lib/ChannelPermissions.js index a9c1bad3a..cebde6bf6 100644 --- a/lib/ChannelPermissions.js +++ b/lib/ChannelPermissions.js @@ -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", diff --git a/lib/EvaluatedPermissions.js b/lib/EvaluatedPermissions.js index ddcbf2128..44107811a 100644 --- a/lib/EvaluatedPermissions.js +++ b/lib/EvaluatedPermissions.js @@ -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", diff --git a/lib/ServerPermissions.js b/lib/ServerPermissions.js index 4c1b48f2d..4960ffcc1 100644 --- a/lib/ServerPermissions.js +++ b/lib/ServerPermissions.js @@ -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() { diff --git a/src/ChannelPermissions.js b/src/ChannelPermissions.js index e3424488b..51316382a 100644 --- a/src/ChannelPermissions.js +++ b/src/ChannelPermissions.js @@ -104,8 +104,17 @@ class ChannelPermissions{ return ((this.packed >>> x) & 1) === 1; } - setBit() { + setBit(location, value){ + if(value){ + // allow that permission + this.packed |= (1 << location); + + }else{ + // not allowed + this.packed &= (1 << location); + } + } } diff --git a/src/EvaluatedPermissions.js b/src/EvaluatedPermissions.js index 00f382915..fbdab9799 100644 --- a/src/EvaluatedPermissions.js +++ b/src/EvaluatedPermissions.js @@ -89,7 +89,16 @@ class EvaluatedPermissions { return ((this.packed >>> x) & 1) === 1; } - setBit() { + setBit(location, value){ + + if(value){ + // allow that permission + this.packed |= (1 << location); + + }else{ + // not allowed + this.packed &= (1 << location); + } } } diff --git a/src/ServerPermissions.js b/src/ServerPermissions.js index 992e9ce66..9146cd0b8 100644 --- a/src/ServerPermissions.js +++ b/src/ServerPermissions.js @@ -107,9 +107,11 @@ class ServerPermissions { if(value){ // allow that permission + this.packed |= (1 << location); }else{ // not allowed + this.packed &= (1 << location); } } diff --git a/test/bot.1.js b/test/bot.1.js index 3ff02710f..f55d98b21 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -31,6 +31,7 @@ mybot.on("message", function (message) { perms = JSON.parse(perms); this.createRole(message.channel.server).catch(error).then((data) => { + data.manageRoles = true; mybot.reply(message, JSON.stringify(data.serialise(), null, 4)); });