From ae0a5c78fa6adfa8f0701ab5fe0c90f132bab71d Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sun, 18 May 2025 14:52:06 -0600 Subject: [PATCH] presence: fetch app icon always --- src/modules/utility/presence.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/modules/utility/presence.js b/src/modules/utility/presence.js index dc8e180..0108063 100644 --- a/src/modules/utility/presence.js +++ b/src/modules/utility/presence.js @@ -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}); } }