diff --git a/webpage/direct.ts b/webpage/direct.ts index 69f18d5..46276c3 100644 --- a/webpage/direct.ts +++ b/webpage/direct.ts @@ -63,6 +63,30 @@ class Direct extends Guild{ } } } + +const dmPermissions = new Permissions("0"); +dmPermissions.setPermission("ADD_REACTIONS",1); +dmPermissions.setPermission("VIEW_CHANNEL",1); +dmPermissions.setPermission("SEND_MESSAGES",1); +dmPermissions.setPermission("EMBED_LINKS",1); +dmPermissions.setPermission("ATTACH_FILES",1); +dmPermissions.setPermission("READ_MESSAGE_HISTORY",1); +dmPermissions.setPermission("MENTION_EVERYONE",1); +dmPermissions.setPermission("USE_EXTERNAL_EMOJIS",1); +dmPermissions.setPermission("USE_APPLICATION_COMMANDS",1); +dmPermissions.setPermission("USE_EXTERNAL_STICKERS",1); +dmPermissions.setPermission("USE_EMBEDDED_ACTIVITIES",1); +dmPermissions.setPermission("USE_SOUNDBOARD",1); +dmPermissions.setPermission("USE_EXTERNAL_SOUNDS",1); +dmPermissions.setPermission("SEND_VOICE_MESSAGES",1); +dmPermissions.setPermission("SEND_POLLS",1); +dmPermissions.setPermission("USE_EXTERNAL_APPS",1); + +dmPermissions.setPermission("CONNECT",1); +dmPermissions.setPermission("SPEAK",1); +dmPermissions.setPermission("STREAM",1); +dmPermissions.setPermission("USE_VAD",1); + class Group extends Channel{ user:User; constructor(json:dirrectjson,owner:Direct){ @@ -188,9 +212,8 @@ class Group extends Channel{ isAdmin(): boolean { return false; } - hasPermission(name: string, member?: Member): boolean { - const perm=new Permissions("248896"); - return !!perm.getPermission(name); + hasPermission(name: string): boolean { + return dmPermissions.hasPermission(name); } } export {Direct, Group}; diff --git a/webpage/permissions.ts b/webpage/permissions.ts index af8841f..b89d492 100644 --- a/webpage/permissions.ts +++ b/webpage/permissions.ts @@ -29,7 +29,7 @@ class Permissions{ Permissions.info=[//for people in the future, do not reorder these, the creation of the map realize on the order { name:"CREATE_INSTANT_INVITE", - readableName:"Create instance invite", + readableName:"Create invite", description:"Allows the user to create invites for the guild" }, { @@ -45,7 +45,7 @@ class Permissions{ { name:"ADMINISTRATOR", readableName:"Administrator", - description:"Allows all permissions and bypasses channel permission overwrites" + description:"Allows all permissions and bypasses channel permission overwrites. This is a dangerous permission!" }, { name:"MANAGE_CHANNELS", @@ -74,17 +74,17 @@ class Permissions{ }, { name:"STREAM", - readableName:"Stream", + readableName:"Video", description:"Allows the user to stream" }, { name:"VIEW_CHANNEL", - readableName:"View channel", + readableName:"View channels", description:"Allows the user to view the channel" }, { name:"SEND_MESSAGES", - readableName:"Send Messages", + readableName:"Send messages", description:"Allows user to send messages" }, { @@ -114,7 +114,7 @@ class Permissions{ }, { name:"MENTION_EVERYONE", - readableName:"Mention everyone", + readableName:"Mention @everyone, @here and all roles", description:"Allows the user to mention everyone" }, { @@ -154,8 +154,8 @@ class Permissions{ }, { name:"USE_VAD", - readableName:"use voice-activity-detection", - description:"Allows user to use voice-activity-detection" + readableName:"Use voice activity detection", + description:"Allows users to speak in a voice channel by simply talking" }, { name:"CHANGE_NICKNAME", @@ -179,7 +179,7 @@ class Permissions{ }, { name:"MANAGE_GUILD_EXPRESSIONS", - readableName:"Manage guild expressions", + readableName:"Manage expressions", description:"Allows for managing emoji, stickers, and soundboards" }, { @@ -224,14 +224,56 @@ class Permissions{ }, { name:"USE_EMBEDDED_ACTIVITIES", - readableName:"Use embedded activities", + readableName:"Use activities", description:"Allows the user to use embedded activities" }, { name:"MODERATE_MEMBERS", - readableName:"Moderate members", + readableName:"Timeout members", description:"Allows the user to time out other users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels" }, + { + name:"VIEW_CREATOR_MONETIZATION_ANALYTICS", + readableName:"View creator monetization analytics", + description:"Allows for viewing role subscription insights" + }, + { + name:"USE_SOUNDBOARD", + readableName:"Use soundboard", + description:"Allows for using soundboard in a voice channel" + }, + { + name:"CREATE_GUILD_EXPRESSIONS", + readableName:"Create expressions", + description:"Allows for creating emojis, stickers, and soundboard sounds, and editing and deleting those created by the current user." + }, + { + name:"CREATE_EVENTS", + readableName:"Create events", + description:"Allows for creating scheduled events, and editing and deleting those created by the current user." + }, + { + name:"USE_EXTERNAL_SOUNDS", + readableName:"Use external sounds", + description:"Allows the usage of custom soundboard sounds from other servers" + }, + { + name:"SEND_VOICE_MESSAGES", + readableName:"Send voice messages", + description:"Allows sending voice messages" + }, + { + name:"SEND_POLLS", + readableName:"Create polls", + description:"Allows sending polls" + }, + { + name:"USE_EXTERNAL_APPS", + readableName:"Use external apps", + description:"Allows user-installed apps to send public responses. " + + "When disabled, users will still be allowed to use their apps but the responses will be ephemeral. " + + "This only applies to apps not also installed to the server." + }, ]; Permissions.map={}; let i=0; @@ -250,8 +292,17 @@ class Permissions{ return 0; } } + hasPermission(name:string):boolean{ + if (this.getPermissionbit(Permissions.map[name] as number,this.allow)) return true; + if (name != "ADMINISTRATOR") return this.hasPermission("ADMINISTRATOR"); + return false; + } setPermission(name:string,setto:number):void{ const bit=Permissions.map[name] as number; + if (!bit) { + return console.error("Tried to set permission to " + setto + " for " + name + " but it doesn't exist"); + } + if(setto===0){ this.deny=this.setPermissionbit(bit,false,this.deny); this.allow=this.setPermissionbit(bit,false,this.allow);