presence: fetch app icon always

This commit is contained in:
Cynthia Foxwell 2025-05-18 14:52:06 -06:00
parent 2fca9ed7a8
commit ae0a5c78fa
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -4,8 +4,8 @@ const sharp = require("sharp");
const {
ActivityTypeNames,
APIEndpoints,
CDNEndpoints,
Games,
/*HangStatusStrings,
HANG_STATUS_ICONS*/
} = require("#util/dconstants.js");
@ -257,6 +257,14 @@ presence.callback = async function (msg, line) {
let thumbnail;
const image_links = [];
let app;
if (activity.application_id)
app = await hf.bot.requestHandler.request(
"GET",
APIEndpoints.APPLICATION_RPC(activity.application_id),
false
);
if (activity.assets) {
if (activity.assets.large_image != null) {
let largeUrl;
@ -316,9 +324,8 @@ presence.callback = async function (msg, line) {
smallUrl = CDNEndpoints.APP_ASSET(activity.application_id, activity.assets.small_image);
}
const game = Games.find((game) => game.id == activity.application_id);
if (game?.icon) {
const gameIcon = `${CDNEndpoints.APP_ICON(game.id, game.icon)}&keep_aspect_ratio=false`;
if (app?.icon) {
const gameIcon = `${CDNEndpoints.APP_ICON(app.id, app.icon)}&keep_aspect_ratio=false`;
image_links.push({label: "App Icon", url: gameIcon});
const largeImage = await fetch(gameIcon)
@ -354,9 +361,8 @@ presence.callback = async function (msg, line) {
}
if (activity.application_id && !activity.assets?.large_image && !activity.assets?.small_image) {
const game = Games.find((game) => game.id == activity.application_id);
if (game?.icon) {
thumbnail = `${CDNEndpoints.APP_ICON(game.id, game.icon)}&keep_aspect_ratio=false`;
if (app?.icon) {
thumbnail = `${CDNEndpoints.APP_ICON(app.id, app.icon)}&keep_aspect_ratio=false`;
image_links.push({label: "App Icon", url: thumbnail});
}
}