catch errors on userpfp & globalbadges

This commit is contained in:
thororen1234 2024-07-18 01:08:04 -04:00
parent 94606a3a5d
commit 0da23d2810
2 changed files with 7 additions and 3 deletions

View file

@ -52,7 +52,8 @@ const fetchBadges = (id: string): BadgeCache["badges"] | undefined => {
.then(body => {
cache.set(id, { badges: body, expires: Date.now() + EXPIRES });
return body;
});
})
.catch(() => null);
} else if (cachedValue) {
return cachedValue.badges;
}

View file

@ -75,7 +75,10 @@ export default definePlugin({
return data.avatars[user.id] ?? original(user, animated, size);
},
async start() {
const res = await fetch(settings.store.urlForDB);
if (res.ok) this.data = data = await res.json();
const res = await fetch(settings.store.urlForDB)
.then(async res => {
if (res.ok) this.data = data = await res.json();
})
.catch(() => null);
}
});