fixed breaking bug with guildids
This commit is contained in:
parent
a1e805aa7f
commit
65eb7db3dd
2 changed files with 36 additions and 28 deletions
|
@ -60,16 +60,16 @@ class Localuser {
|
||||||
for (const thing of ready.d.guilds) {
|
for (const thing of ready.d.guilds) {
|
||||||
const temp = new Guild(thing, this, members[thing.id]);
|
const temp = new Guild(thing, this, members[thing.id]);
|
||||||
this.guilds.push(temp);
|
this.guilds.push(temp);
|
||||||
this.guildids[temp.id] = temp;
|
this.guildids.set(temp.id, temp);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const temp = new Direct(ready.d.private_channels, this);
|
const temp = new Direct(ready.d.private_channels, this);
|
||||||
this.guilds.push(temp);
|
this.guilds.push(temp);
|
||||||
this.guildids[temp.id] = temp;
|
this.guildids.set(temp.id, temp);
|
||||||
}
|
}
|
||||||
console.log(ready.d.user_guild_settings.entries);
|
console.log(ready.d.user_guild_settings.entries);
|
||||||
for (const thing of 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) {
|
for (const thing of ready.d.read_state.entries) {
|
||||||
const channel = this.resolveChannelFromID(thing.id);
|
const channel = this.resolveChannelFromID(thing.id);
|
||||||
|
@ -81,7 +81,7 @@ class Localuser {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const guildid = guild.snowflake;
|
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 = [];
|
this.typing = [];
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ class Localuser {
|
||||||
break;
|
break;
|
||||||
case "GUILD_DELETE":
|
case "GUILD_DELETE":
|
||||||
{
|
{
|
||||||
const guildy = this.guildids[temp.d.id];
|
const guildy = this.guildids.get(temp.d.id);
|
||||||
delete this.guildids[temp.d.id];
|
this.guildids.delete(temp.d.id);
|
||||||
this.guilds.splice(this.guilds.indexOf(guildy), 1);
|
this.guilds.splice(this.guilds.indexOf(guildy), 1);
|
||||||
guildy.html.remove();
|
guildy.html.remove();
|
||||||
break;
|
break;
|
||||||
|
@ -193,7 +193,7 @@ class Localuser {
|
||||||
{
|
{
|
||||||
const guildy = new Guild(temp.d, this, this.user);
|
const guildy = new Guild(temp.d, this, this.user);
|
||||||
this.guilds.push(guildy);
|
this.guilds.push(guildy);
|
||||||
this.guildids[guildy.id] = guildy;
|
this.guildids.set(guildy.id, guildy);
|
||||||
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(), document.getElementById("bottomseparator"));
|
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(), document.getElementById("bottomseparator"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ class Localuser {
|
||||||
}
|
}
|
||||||
delChannel(JSON) {
|
delChannel(JSON) {
|
||||||
JSON.guild_id ??= "@me";
|
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) {
|
if (JSON.guild_id === this.lookingguild.snowflake) {
|
||||||
this.loadGuild(JSON.guild_id);
|
this.loadGuild(JSON.guild_id);
|
||||||
}
|
}
|
||||||
|
@ -287,10 +287,11 @@ class Localuser {
|
||||||
return this.lookingguild.isAdmin();
|
return this.lookingguild.isAdmin();
|
||||||
}
|
}
|
||||||
loadGuild(id) {
|
loadGuild(id) {
|
||||||
let guild = this.guildids[id];
|
let guild = this.guildids.get(id);
|
||||||
if (!guild) {
|
if (!guild) {
|
||||||
guild = this.guildids["@me"];
|
guild = this.guildids.get("@me");
|
||||||
}
|
}
|
||||||
|
console.log(this.guildids, id, guild);
|
||||||
if (this.lookingguild) {
|
if (this.lookingguild) {
|
||||||
this.lookingguild.html.classList.remove("serveropen");
|
this.lookingguild.html.classList.remove("serveropen");
|
||||||
}
|
}
|
||||||
|
@ -310,8 +311,8 @@ class Localuser {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
div.textContent = "⌂";
|
div.textContent = "⌂";
|
||||||
div.classList.add("home", "servericon");
|
div.classList.add("home", "servericon");
|
||||||
div["all"] = this.guildids["@me"];
|
div["all"] = this.guildids.get("@me");
|
||||||
this.guildids["@me"].html = outdiv;
|
this.guildids.get("@me").html = outdiv;
|
||||||
const unread = document.createElement("div");
|
const unread = document.createElement("div");
|
||||||
unread.classList.add("unread");
|
unread.classList.add("unread");
|
||||||
outdiv.append(unread);
|
outdiv.append(unread);
|
||||||
|
@ -358,6 +359,7 @@ class Localuser {
|
||||||
this.guildDiscovery();
|
this.guildDiscovery();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log("test");
|
||||||
this.unreads();
|
this.unreads();
|
||||||
}
|
}
|
||||||
createGuild() {
|
createGuild() {
|
||||||
|
@ -460,7 +462,7 @@ class Localuser {
|
||||||
}
|
}
|
||||||
messageCreate(messagep) {
|
messageCreate(messagep) {
|
||||||
messagep.d.guild_id ??= "@me";
|
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();
|
this.unreads();
|
||||||
}
|
}
|
||||||
unreads() {
|
unreads() {
|
||||||
|
@ -469,7 +471,9 @@ class Localuser {
|
||||||
if (thing.id === "@me") {
|
if (thing.id === "@me") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
thing.unreads(this.guildhtml[thing.id]);
|
const html = this.guildhtml.get(thing.id);
|
||||||
|
console.log(html);
|
||||||
|
thing.unreads(html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typingStart(typing) {
|
typingStart(typing) {
|
||||||
|
|
|
@ -64,18 +64,18 @@ class Localuser{
|
||||||
for(const thing of ready.d.guilds){
|
for(const thing of ready.d.guilds){
|
||||||
const temp=new Guild(thing,this,members[thing.id]);
|
const temp=new Guild(thing,this,members[thing.id]);
|
||||||
this.guilds.push(temp);
|
this.guilds.push(temp);
|
||||||
this.guildids[temp.id]=temp;
|
this.guildids.set(temp.id,temp);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const temp=new Direct(ready.d.private_channels,this);
|
const temp=new Direct(ready.d.private_channels,this);
|
||||||
this.guilds.push(temp);
|
this.guilds.push(temp);
|
||||||
this.guildids[temp.id]=temp;
|
this.guildids.set(temp.id,temp);
|
||||||
}
|
}
|
||||||
console.log(ready.d.user_guild_settings.entries);
|
console.log(ready.d.user_guild_settings.entries);
|
||||||
|
|
||||||
|
|
||||||
for(const thing of 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){
|
for(const thing of ready.d.read_state.entries){
|
||||||
|
@ -86,7 +86,7 @@ class Localuser{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const guildid=guild.snowflake;
|
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=[];
|
this.typing=[];
|
||||||
}
|
}
|
||||||
|
@ -192,8 +192,8 @@ class Localuser{
|
||||||
break;
|
break;
|
||||||
case "GUILD_DELETE":
|
case "GUILD_DELETE":
|
||||||
{
|
{
|
||||||
const guildy=this.guildids[temp.d.id];
|
const guildy=this.guildids.get(temp.d.id);
|
||||||
delete this.guildids[temp.d.id];
|
this.guildids.delete(temp.d.id);
|
||||||
this.guilds.splice(this.guilds.indexOf(guildy),1);
|
this.guilds.splice(this.guilds.indexOf(guildy),1);
|
||||||
guildy.html.remove();
|
guildy.html.remove();
|
||||||
break;
|
break;
|
||||||
|
@ -202,7 +202,7 @@ class Localuser{
|
||||||
{
|
{
|
||||||
const guildy=new Guild(temp.d,this,this.user);
|
const guildy=new Guild(temp.d,this,this.user);
|
||||||
this.guilds.push(guildy);
|
this.guilds.push(guildy);
|
||||||
this.guildids[guildy.id]=guildy;
|
this.guildids.set(guildy.id,guildy);
|
||||||
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(),document.getElementById("bottomseparator"));
|
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(),document.getElementById("bottomseparator"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ class Localuser{
|
||||||
}
|
}
|
||||||
delChannel(JSON):void{
|
delChannel(JSON):void{
|
||||||
JSON.guild_id??="@me";
|
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){
|
if(JSON.guild_id===this.lookingguild.snowflake){
|
||||||
this.loadGuild(JSON.guild_id);
|
this.loadGuild(JSON.guild_id);
|
||||||
|
@ -301,10 +301,11 @@ class Localuser{
|
||||||
return this.lookingguild.isAdmin();
|
return this.lookingguild.isAdmin();
|
||||||
}
|
}
|
||||||
loadGuild(id:string):Guild{
|
loadGuild(id:string):Guild{
|
||||||
let guild=this.guildids[id];
|
let guild=this.guildids.get(id);
|
||||||
if(!guild){
|
if(!guild){
|
||||||
guild=this.guildids["@me"];
|
guild=this.guildids.get("@me");
|
||||||
}
|
}
|
||||||
|
console.log(this.guildids,id,guild);
|
||||||
if(this.lookingguild){
|
if(this.lookingguild){
|
||||||
this.lookingguild.html.classList.remove("serveropen");
|
this.lookingguild.html.classList.remove("serveropen");
|
||||||
}
|
}
|
||||||
|
@ -325,8 +326,8 @@ class Localuser{
|
||||||
|
|
||||||
div.textContent="⌂";
|
div.textContent="⌂";
|
||||||
div.classList.add("home","servericon")
|
div.classList.add("home","servericon")
|
||||||
div["all"]=this.guildids["@me"];
|
div["all"]=this.guildids.get("@me");
|
||||||
this.guildids["@me"].html=outdiv;
|
this.guildids.get("@me").html=outdiv;
|
||||||
const unread=document.createElement("div");
|
const unread=document.createElement("div");
|
||||||
unread.classList.add("unread");
|
unread.classList.add("unread");
|
||||||
outdiv.append(unread);
|
outdiv.append(unread);
|
||||||
|
@ -378,6 +379,7 @@ class Localuser{
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
console.log("test");
|
||||||
this.unreads();
|
this.unreads();
|
||||||
}
|
}
|
||||||
createGuild(){
|
createGuild(){
|
||||||
|
@ -489,14 +491,16 @@ class Localuser{
|
||||||
}
|
}
|
||||||
messageCreate(messagep):void{
|
messageCreate(messagep):void{
|
||||||
messagep.d.guild_id??="@me";
|
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();
|
this.unreads();
|
||||||
}
|
}
|
||||||
unreads():void{
|
unreads():void{
|
||||||
console.log(this.guildhtml)
|
console.log(this.guildhtml)
|
||||||
for(const thing of this.guilds){
|
for(const thing of this.guilds){
|
||||||
if(thing.id==="@me"){continue;}
|
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{
|
typingStart(typing):void{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue