remove snowflake instances

This commit is contained in:
MathMan05 2024-09-03 11:00:44 -05:00
parent 004beb4955
commit e66b6c0883
16 changed files with 97 additions and 149 deletions

View file

@ -10,12 +10,11 @@ import{ SnowFlake }from"./snowflake.js";
import{ channeljson, guildjson, emojijson, memberjson }from"./jsontypes.js";
import{ User }from"./user.js";
import{ Message }from"./message.js";
class Guild{
class Guild extends SnowFlake{
owner:Localuser;
headers:Localuser["headers"];
channels:Channel[];
channelids:{[key:string]:Channel};
snowflake:SnowFlake;
properties;
roles:Role[];
roleids:Map<string,Role>;
@ -27,9 +26,6 @@ class Guild{
member:Member;
html:HTMLElement;
emojis:emojijson[];
get id(){
return this.snowflake.id;
}
static contextmenu=new Contextmenu<Guild,undefined>("guild menu");
static setupcontextmenu(){
Guild.contextmenu.addbutton("Copy Guild id",function(this:Guild){
@ -87,20 +83,20 @@ class Guild{
s1.options.push(new RoleList(permlist,this,this.updateRolePermissions.bind(this)));
settings.show();
}
constructor(json:guildjson|-1,owner:Localuser,member:memberjson|User|null){
if(json===-1||member===null){
constructor(json:guildjson|-1,owner:Localuser,member:memberjson|User){
if(json===-1){
super("@me");
return;
}
if(json.stickers.length){
console.log(json.stickers,":3");
}
super(json.id);
this.emojis = json.emojis;
this.owner=owner;
this.headers=this.owner.headers;
this.channels=[];
this.channelids={};
this.snowflake=new SnowFlake(json.id);
this.properties=json.properties;
this.roles=[];
this.roleids=new Map();
@ -203,7 +199,7 @@ class Guild{
full.show();
}
async leave(){
return fetch(this.info.api+"/users/@me/guilds/"+this.snowflake,{
return fetch(this.info.api+"/users/@me/guilds/"+this.id,{
method: "DELETE",
headers: this.headers
});
@ -351,7 +347,7 @@ class Guild{
full.show();
}
async delete(){
return fetch(this.info.api+"/guilds/"+this.snowflake+"/delete",{
return fetch(this.info.api+"/guilds/"+this.id+"/delete",{
method: "POST",
headers: this.headers,
});
@ -543,7 +539,7 @@ class Guild{
});
}
async createRole(name:string){
const fetched=await fetch(this.info.api+"/guilds/"+this.snowflake+"roles",{
const fetched=await fetch(this.info.api+"/guilds/"+this.id+"roles",{
method: "POST",
headers: this.headers,
body: JSON.stringify({
@ -563,7 +559,7 @@ class Guild{
role.permissions.allow=perms.allow;
role.permissions.deny=perms.deny;
await fetch(this.info.api+"/guilds/"+this.snowflake+"/roles/"+this.snowflake,{
await fetch(this.info.api+"/guilds/"+this.id+"/roles/"+role.id,{
method: "PATCH",
headers: this.headers,
body: JSON.stringify({