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:bigint;
deny:bigint;
readonly hasDeny:boolean;
constructor(allow:string,deny:string=""){
this.hasDeny=!!deny;
this.allow=BigInt(allow);
this.deny=BigInt(deny);
}
@ -86,7 +88,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,22 @@ class Permissions{
return 0;
}
}
setPermision(name:string,setto:number):void{
const bit=Permissions.map[name] as number;
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();