make guild icons update

This commit is contained in:
MathMan05 2025-03-15 14:55:23 -05:00
parent a2a53e5c88
commit cf820653ee
3 changed files with 14 additions and 4 deletions

View file

@ -440,8 +440,14 @@ class Guild extends SnowFlake {
this.emojis = json.emojis;
this.headers = this.owner.headers;
this.channels = [];
this.roles = [];
if (this.properties.icon !== json.icon) {
this.properties.icon = json.icon;
if (this.HTMLicon) {
const divy = this.generateGuildIcon();
this.HTMLicon.replaceWith(divy);
this.HTMLicon = divy;
}
}
this.roleids = new Map();
this.banner = json.banner;
}
@ -666,6 +672,7 @@ class Guild extends SnowFlake {
return a.position - b.position;
});
}
HTMLicon?: HTMLElement;
static generateGuildIcon(guild: Guild | (invitejson["guild"] & {info: {cdn: string}})) {
const divy = document.createElement("div");
divy.classList.add("servernoti");

View file

@ -490,8 +490,10 @@ class Localuser {
const guildy = new Guild(temp.d, this, this.user);
this.guilds.push(guildy);
this.guildids.set(guildy.id, guildy);
const divy = guildy.generateGuildIcon();
guildy.HTMLicon = divy;
(document.getElementById("servers") as HTMLDivElement).insertBefore(
guildy.generateGuildIcon(),
divy,
document.getElementById("bottomseparator"),
);
})();
@ -966,6 +968,7 @@ class Localuser {
continue;
}
const divy = thing.generateGuildIcon();
thing.HTMLicon = divy;
serverlist.append(divy);
}
{

View file

@ -387,7 +387,7 @@ class Member extends SnowFlake {
}
static async resolveMember(user: User, guild: Guild): Promise<Member | undefined> {
const maybe = user.members.get(guild);
if (!user.members.has(guild)) {
if (!maybe) {
const membpromise = guild.localuser.resolvemember(user.id, guild.id);
const promise = new Promise<Member | undefined>(async (res) => {
const membjson = await membpromise;