adds support for role settings and various fixes

This commit is contained in:
MathMan05
2024-06-30 22:05:14 -05:00
parent 96b2dbb21c
commit 8fe0c9f46b
20 changed files with 1199 additions and 183 deletions

View File

@@ -2,7 +2,9 @@ export { Permissions };
class Permissions {
allow;
deny;
hasDeny;
constructor(allow, deny = "") {
this.hasDeny = !!deny;
this.allow = BigInt(allow);
this.deny = BigInt(deny);
}
@@ -84,7 +86,7 @@ class Permissions {
},
{
name: "MANAGE_MESSAGES",
readableName: "Manager messages",
readableName: "Manage messages",
description: "Allows the user to delete messages that aren't their own"
},
{
@@ -242,5 +244,23 @@ class Permissions {
return 0;
}
}
setPermision(name, setto) {
const bit = Permissions.map[name];
if (setto === 0) {
this.deny = this.setPermisionbit(bit, false, this.deny);
this.allow = this.setPermisionbit(bit, false, this.allow);
}
else if (setto === 1) {
this.deny = this.setPermisionbit(bit, false, this.deny);
this.allow = this.setPermisionbit(bit, true, this.allow);
}
else if (setto === -1) {
this.deny = this.setPermisionbit(bit, true, this.deny);
this.allow = this.setPermisionbit(bit, false, this.allow);
}
else {
console.error("invalid number entered:" + setto);
}
}
}
Permissions.makeMap();