fix id and snowflake
This commit is contained in:
parent
5e9405207b
commit
4f80104e2e
17 changed files with 263 additions and 235 deletions
|
@ -12,7 +12,7 @@ class Guild{
|
|||
headers:Localuser["headers"];
|
||||
channels:Channel[];
|
||||
channelids:{[key:string]:Channel};
|
||||
id:SnowFlake<Guild>;
|
||||
snowflake:SnowFlake<Guild>;
|
||||
properties
|
||||
roles:Role[];
|
||||
roleids:Map<SnowFlake<Role>,Role>;
|
||||
|
@ -23,6 +23,9 @@ class Guild{
|
|||
parent_id:string;
|
||||
member:Member;
|
||||
html:HTMLElement;
|
||||
get id(){
|
||||
return this.snowflake.id;
|
||||
}
|
||||
static contextmenu=new Contextmenu("guild menu");
|
||||
static setupcontextmenu(){
|
||||
Guild.contextmenu.addbutton("Copy Guild id",function(){
|
||||
|
@ -71,7 +74,7 @@ class Guild{
|
|||
const s1=settings.addButton("roles");
|
||||
const permlist=[];
|
||||
for(const thing of this.roles){
|
||||
permlist.push([thing.id,thing.permissions]);
|
||||
permlist.push([thing.snowflake,thing.permissions]);
|
||||
}
|
||||
s1.options.push(new RoleList(permlist,this,this.updateRolePermissions.bind(this)));
|
||||
settings.show();
|
||||
|
@ -84,7 +87,7 @@ class Guild{
|
|||
this.headers=this.owner.headers;
|
||||
this.channels=[];
|
||||
this.channelids={};
|
||||
this.id=new SnowFlake(json.id,this);
|
||||
this.snowflake=new SnowFlake(json.id,this);
|
||||
this.properties=json.properties;
|
||||
this.roles=[];
|
||||
this.roleids=new Map();
|
||||
|
@ -93,13 +96,13 @@ class Guild{
|
|||
for(const roley of json.roles){
|
||||
const roleh=new Role(roley,this);
|
||||
this.roles.push(roleh)
|
||||
this.roleids.set(roleh.id,roleh);
|
||||
this.roleids.set(roleh.snowflake,roleh);
|
||||
}
|
||||
Member.resolve(member,this).then(_=>this.member=_);
|
||||
for(const thing of json.channels){
|
||||
const temp=new Channel(thing,this);
|
||||
this.channels.push(temp);
|
||||
this.channelids[temp.id.id]=temp;
|
||||
this.channelids[temp.id]=temp;
|
||||
}
|
||||
this.headchannels=[];
|
||||
for(const thing of this.channels){
|
||||
|
@ -129,7 +132,7 @@ class Guild{
|
|||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
"guilds":{
|
||||
[this.id.id]:{
|
||||
[this.id]:{
|
||||
"message_notifications": noti
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +172,7 @@ class Guild{
|
|||
full.show();
|
||||
}
|
||||
async leave(){
|
||||
return fetch(this.info.api.toString()+"/users/@me/guilds/"+this.id,{
|
||||
return fetch(this.info.api.toString()+"/users/@me/guilds/"+this.snowflake,{
|
||||
method:"DELETE",
|
||||
headers:this.headers
|
||||
})
|
||||
|
@ -188,7 +191,7 @@ class Guild{
|
|||
let position=-1;
|
||||
let build=[];
|
||||
for(const thing of this.headchannels){
|
||||
const thisthing={id:thing.id,position:undefined,parent_id:undefined}
|
||||
const thisthing={id:thing.snowflake,position:undefined,parent_id:undefined}
|
||||
if(thing.position<=position){
|
||||
thing.position=(thisthing.position=position+1);
|
||||
}
|
||||
|
@ -217,14 +220,14 @@ class Guild{
|
|||
if(serverbug){
|
||||
for(const thing of build){
|
||||
console.log(build,thing)
|
||||
fetch(this.info.api.toString()+"/v9/guilds/"+this.id+"/channels",{
|
||||
fetch(this.info.api.toString()+"/v9/guilds/"+this.snowflake+"/channels",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify([thing])
|
||||
});
|
||||
}
|
||||
}else{
|
||||
fetch(this.info.api.toString()+"/v9/guilds/"+this.id+"/channels",{
|
||||
fetch(this.info.api.toString()+"/v9/guilds/"+this.snowflake+"/channels",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify(build)
|
||||
|
@ -248,7 +251,7 @@ class Guild{
|
|||
const noti=document.createElement("div");
|
||||
noti.classList.add("unread");
|
||||
divy.append(noti);
|
||||
this.localuser.guildhtml[this.id.id]=divy;
|
||||
this.localuser.guildhtml.set(this.id,divy);
|
||||
if(this.properties.icon!=null){
|
||||
const img=document.createElement("img");
|
||||
img.classList.add("pfp","servericon");
|
||||
|
@ -319,7 +322,7 @@ class Guild{
|
|||
full.show();
|
||||
}
|
||||
async delete(){
|
||||
return fetch(this.info.api.toString()+"/guilds/"+this.id+"/delete",{
|
||||
return fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/delete",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
})
|
||||
|
@ -362,7 +365,7 @@ class Guild{
|
|||
const build={read_states:[]};
|
||||
for(const thing of this.channels){
|
||||
if(thing.hasunreads){
|
||||
build.read_states.push({channel_id:thing.id,message_id:thing.lastmessageid,read_state_type:0});
|
||||
build.read_states.push({channel_id:thing.snowflake,message_id:thing.lastmessageid,read_state_type:0});
|
||||
thing.lastreadmessageid=thing.lastmessageid;
|
||||
thing.myhtml.classList.remove("cunread");
|
||||
}
|
||||
|
@ -377,7 +380,7 @@ class Guild{
|
|||
hasRole(r:Role|string){
|
||||
console.log("this should run");
|
||||
if(r instanceof Role){
|
||||
r=r.id.id;
|
||||
r=r.id;
|
||||
}
|
||||
return this.member.hasRole(r);
|
||||
}
|
||||
|
@ -399,7 +402,7 @@ class Guild{
|
|||
}
|
||||
}
|
||||
loadGuild(){
|
||||
this.localuser.loadGuild(this.id.id);
|
||||
this.localuser.loadGuild(this.id);
|
||||
}
|
||||
updateChannel(JSON){
|
||||
SnowFlake.getSnowFlakeFromID(JSON.id,Channel).getObject().updateChannel(JSON);
|
||||
|
@ -495,14 +498,14 @@ class Guild{
|
|||
this.printServers();
|
||||
}
|
||||
createChannel(name:string,type:number){
|
||||
fetch(this.info.api.toString()+"/guilds/"+this.id+"/channels",{
|
||||
fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/channels",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({name: name, type: type})
|
||||
})
|
||||
}
|
||||
async createRole(name:string){
|
||||
const fetched=await fetch(this.info.api.toString()+"/guilds/"+this.id+"roles",{
|
||||
const fetched=await fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"roles",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -513,7 +516,7 @@ class Guild{
|
|||
})
|
||||
const json=await fetched.json();
|
||||
const role=new Role(json,this);
|
||||
this.roleids[role.id.id]=role;
|
||||
this.roleids.set(role.snowflake,role);
|
||||
this.roles.push(role);
|
||||
return role;
|
||||
}
|
||||
|
@ -522,7 +525,7 @@ class Guild{
|
|||
role.permissions.allow=perms.allow;
|
||||
role.permissions.deny=perms.deny;
|
||||
|
||||
await fetch(this.info.api.toString()+"/guilds/"+this.id+"/roles/"+this.id,{
|
||||
await fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/roles/"+this.snowflake,{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue