fixed breaking bug with guildids

This commit is contained in:
MathMan05 2024-07-24 13:07:53 -05:00
parent a1e805aa7f
commit 65eb7db3dd
2 changed files with 36 additions and 28 deletions

View file

@ -64,18 +64,18 @@ class Localuser{
for(const thing of ready.d.guilds){
const temp=new Guild(thing,this,members[thing.id]);
this.guilds.push(temp);
this.guildids[temp.id]=temp;
this.guildids.set(temp.id,temp);
}
{
const temp=new Direct(ready.d.private_channels,this);
this.guilds.push(temp);
this.guildids[temp.id]=temp;
this.guildids.set(temp.id,temp);
}
console.log(ready.d.user_guild_settings.entries);
for(const thing of ready.d.user_guild_settings.entries){
this.guildids[thing.guild_id].notisetting(thing);
this.guildids.get(thing.guild_id).notisetting(thing);
}
for(const thing of ready.d.read_state.entries){
@ -86,7 +86,7 @@ class Localuser{
continue
}
const guildid=guild.snowflake;
this.guildids[guildid.id].channelids[thing.channel_id].readStateInfo(thing);
this.guildids.get(guildid.id).channelids[thing.channel_id].readStateInfo(thing);
}
this.typing=[];
}
@ -192,8 +192,8 @@ class Localuser{
break;
case "GUILD_DELETE":
{
const guildy=this.guildids[temp.d.id];
delete this.guildids[temp.d.id];
const guildy=this.guildids.get(temp.d.id);
this.guildids.delete(temp.d.id);
this.guilds.splice(this.guilds.indexOf(guildy),1);
guildy.html.remove();
break;
@ -202,7 +202,7 @@ class Localuser{
{
const guildy=new Guild(temp.d,this,this.user);
this.guilds.push(guildy);
this.guildids[guildy.id]=guildy;
this.guildids.set(guildy.id,guildy);
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(),document.getElementById("bottomseparator"));
}
}
@ -276,7 +276,7 @@ class Localuser{
}
delChannel(JSON):void{
JSON.guild_id??="@me";
this.guildids[JSON.guild_id].delChannel(JSON);
this.guildids.get(JSON.guild_id).delChannel(JSON);
if(JSON.guild_id===this.lookingguild.snowflake){
this.loadGuild(JSON.guild_id);
@ -301,10 +301,11 @@ class Localuser{
return this.lookingguild.isAdmin();
}
loadGuild(id:string):Guild{
let guild=this.guildids[id];
let guild=this.guildids.get(id);
if(!guild){
guild=this.guildids["@me"];
guild=this.guildids.get("@me");
}
console.log(this.guildids,id,guild);
if(this.lookingguild){
this.lookingguild.html.classList.remove("serveropen");
}
@ -325,8 +326,8 @@ class Localuser{
div.textContent="⌂";
div.classList.add("home","servericon")
div["all"]=this.guildids["@me"];
this.guildids["@me"].html=outdiv;
div["all"]=this.guildids.get("@me");
this.guildids.get("@me").html=outdiv;
const unread=document.createElement("div");
unread.classList.add("unread");
outdiv.append(unread);
@ -378,6 +379,7 @@ class Localuser{
});
}
console.log("test");
this.unreads();
}
createGuild(){
@ -489,14 +491,16 @@ class Localuser{
}
messageCreate(messagep):void{
messagep.d.guild_id??="@me";
this.guildids[messagep.d.guild_id].channelids[messagep.d.channel_id].messageCreate(messagep);
this.guildids.get(messagep.d.guild_id).channelids[messagep.d.channel_id].messageCreate(messagep);
this.unreads();
}
unreads():void{
console.log(this.guildhtml)
for(const thing of this.guilds){
if(thing.id==="@me"){continue;}
thing.unreads(this.guildhtml[thing.id]);
const html=this.guildhtml.get(thing.id);
console.log(html);
thing.unreads(html);
}
}
typingStart(typing):void{