fixing guild/channel creation

This commit is contained in:
MathMan05 2024-11-12 13:46:44 -06:00
parent ebce301cbf
commit 71aa1c0e9b
4 changed files with 18 additions and 13 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "jankclient", "name": "jankclient",
"version": "0.1.0", "version": "0.2.0",
"description": "A SpaceBar Client written in TS HTML and CSS to run, clone the repo and do either `npm start` or `bun start` both bun and node are supported, and both should function as expected. To access Jank Client after init simply go to http://localhost:8080/login and login with your username and password.", "description": "A SpaceBar Client written in TS HTML and CSS to run, clone the repo and do either `npm start` or `bun start` both bun and node are supported, and both should function as expected. To access Jank Client after init simply go to http://localhost:8080/login and login with your username and password.",
"main": ".dist/index.js", "main": ".dist/index.js",
"type": "module", "type": "module",
@ -15,8 +15,8 @@
"@html-eslint/parser": "^0.27.0", "@html-eslint/parser": "^0.27.0",
"@stylistic/eslint-plugin-js": "^2.8.0", "@stylistic/eslint-plugin-js": "^2.8.0",
"@swc/core": "^1.7.26", "@swc/core": "^1.7.26",
"@typescript-eslint/eslint-plugin": "^8.6.0", "@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.6.0", "@typescript-eslint/parser": "^8.14.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"eslint-plugin-html": "^8.1.1", "eslint-plugin-html": "^8.1.1",
"express": "^4.19.2", "express": "^4.19.2",
@ -41,6 +41,6 @@
"gulp-plumber": "^1.2.1", "gulp-plumber": "^1.2.1",
"gulp-typescript": "^6.0.0-alpha.1", "gulp-typescript": "^6.0.0-alpha.1",
"typescript": "^5.6.2", "typescript": "^5.6.2",
"typescript-eslint": "^8.6.0" "typescript-eslint": "^8.14.0"
} }
} }

View file

@ -208,6 +208,7 @@ class Guild extends SnowFlake{
} }
this.sortRoles(); this.sortRoles();
if(member instanceof User){ if(member instanceof User){
console.warn(member);
Member.resolveMember(member, this).then(_=>{ Member.resolveMember(member, this).then(_=>{
if(_){ if(_){
this.member = _; this.member = _;
@ -415,6 +416,7 @@ class Guild extends SnowFlake{
divy.append(noti); divy.append(noti);
if(guild instanceof Guild){ if(guild instanceof Guild){
guild.localuser.guildhtml.set(guild.id, divy); guild.localuser.guildhtml.set(guild.id, divy);
guild.html=divy;
} }
let icon: string | null; let icon: string | null;
if(guild instanceof Guild){ if(guild instanceof Guild){

View file

@ -436,7 +436,7 @@ class Localuser{
} }
break; break;
} }
case"GUILD_CREATE": { case"GUILD_CREATE": (async()=>{
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.set(guildy.id, guildy); this.guildids.set(guildy.id, guildy);
@ -444,8 +444,9 @@ class Localuser{
guildy.generateGuildIcon(), guildy.generateGuildIcon(),
document.getElementById("bottomseparator") document.getElementById("bottomseparator")
); );
})();
break; break;
}
case"MESSAGE_REACTION_ADD": case"MESSAGE_REACTION_ADD":
{ {
temp.d.guild_id ??= "@me"; temp.d.guild_id ??= "@me";
@ -600,7 +601,7 @@ class Localuser{
if(!guild)return; if(!guild)return;
const channel = guild.createChannelpac(json); const channel = guild.createChannelpac(json);
if(json.guild_id === this.lookingguild?.id){ if(json.guild_id === this.lookingguild?.id){
this.loadGuild(json.guild_id); this.loadGuild(json.guild_id,true);
} }
if(channel.id === this.gotoid){ if(channel.id === this.gotoid){
guild.loadGuild(); guild.loadGuild();
@ -743,7 +744,7 @@ class Localuser{
} }
if(json.guild_id === this.lookingguild?.id){ if(json.guild_id === this.lookingguild?.id){
this.loadGuild(json.guild_id); this.loadGuild(json.guild_id,true);
} }
} }
init(): void{ init(): void{
@ -770,12 +771,13 @@ class Localuser{
return false; return false;
} }
} }
loadGuild(id: string): Guild | undefined{ loadGuild(id: string,forceReload=false): Guild | undefined{
let guild = this.guildids.get(id); let guild = this.guildids.get(id);
if(!guild){ if(!guild){
guild = this.guildids.get("@me"); guild = this.guildids.get("@me");
} }
if(this.lookingguild === guild){ console.log(forceReload);
if((!forceReload)&&(this.lookingguild === guild)){
return guild; return guild;
} }
if(this.channelfocus){ if(this.channelfocus){
@ -1939,11 +1941,11 @@ class Localuser{
} }
const guild = this.guildids.get(guildid); const guild = this.guildids.get(guildid);
const borked = true; const borked = true;
if(borked && guild && guild.member_count > 250){ if( !guild || borked && guild.member_count > 250){
//sorry puyo, I need to fix member resolving while it's broken on large guilds //sorry puyo, I need to fix member resolving while it's broken on large guilds
try{ try{
const req = await fetch( const req = await fetch(
this.info.api + "/guilds/" + guild.id + "/members/" + id, this.info.api + "/guilds/" + guildid + "/members/" + id,
{ {
headers: this.headers, headers: this.headers,
} }

View file

@ -158,6 +158,7 @@ class Member extends SnowFlake{
} }
}); });
user.members.set(guild, promise); user.members.set(guild, promise);
return await promise;
} }
if(maybe instanceof Promise){ if(maybe instanceof Promise){
return await maybe; return await maybe;