mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 13:33:30 +01:00
Added setting permissions
You should just do: permissionObject.manageRoles = true; for example rather than messing with setBit.
This commit is contained in:
@@ -59,7 +59,16 @@ var ChannelPermissions = (function () {
|
|||||||
return (this.packed >>> x & 1) === 1;
|
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, [{
|
_createClass(ChannelPermissions, [{
|
||||||
key: "createInstantInvite",
|
key: "createInstantInvite",
|
||||||
|
|||||||
@@ -44,7 +44,16 @@ var EvaluatedPermissions = (function () {
|
|||||||
return (this.packed >>> x & 1) === 1;
|
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, [{
|
_createClass(EvaluatedPermissions, [{
|
||||||
key: "createInstantInvite",
|
key: "createInstantInvite",
|
||||||
|
|||||||
@@ -52,10 +52,11 @@ var ServerPermissions = (function () {
|
|||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
// allow that permission
|
// allow that permission
|
||||||
|
this.packed |= 1 << location;
|
||||||
} else {
|
} else {
|
||||||
// not allowed
|
// not allowed
|
||||||
}
|
this.packed &= 1 << location;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ServerPermissions.prototype.toString = function toString() {
|
ServerPermissions.prototype.toString = function toString() {
|
||||||
|
|||||||
@@ -104,7 +104,16 @@ class ChannelPermissions{
|
|||||||
return ((this.packed >>> x) & 1) === 1;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,16 @@ class EvaluatedPermissions {
|
|||||||
return ((this.packed >>> x) & 1) === 1;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,9 +107,11 @@ class ServerPermissions {
|
|||||||
|
|
||||||
if(value){
|
if(value){
|
||||||
// allow that permission
|
// allow that permission
|
||||||
|
this.packed |= (1 << location);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// not allowed
|
// not allowed
|
||||||
|
this.packed &= (1 << location);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ mybot.on("message", function (message) {
|
|||||||
perms = JSON.parse(perms);
|
perms = JSON.parse(perms);
|
||||||
|
|
||||||
this.createRole(message.channel.server).catch(error).then((data) => {
|
this.createRole(message.channel.server).catch(error).then((data) => {
|
||||||
|
data.manageRoles = true;
|
||||||
mybot.reply(message, JSON.stringify(data.serialise(), null, 4));
|
mybot.reply(message, JSON.stringify(data.serialise(), null, 4));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user