presence: fetch app icon always
This commit is contained in:
parent
2fca9ed7a8
commit
ae0a5c78fa
1 changed files with 13 additions and 7 deletions
|
@ -4,8 +4,8 @@ const sharp = require("sharp");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ActivityTypeNames,
|
ActivityTypeNames,
|
||||||
|
APIEndpoints,
|
||||||
CDNEndpoints,
|
CDNEndpoints,
|
||||||
Games,
|
|
||||||
/*HangStatusStrings,
|
/*HangStatusStrings,
|
||||||
HANG_STATUS_ICONS*/
|
HANG_STATUS_ICONS*/
|
||||||
} = require("#util/dconstants.js");
|
} = require("#util/dconstants.js");
|
||||||
|
@ -257,6 +257,14 @@ presence.callback = async function (msg, line) {
|
||||||
let thumbnail;
|
let thumbnail;
|
||||||
const image_links = [];
|
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) {
|
||||||
if (activity.assets.large_image != null) {
|
if (activity.assets.large_image != null) {
|
||||||
let largeUrl;
|
let largeUrl;
|
||||||
|
@ -316,9 +324,8 @@ presence.callback = async function (msg, line) {
|
||||||
smallUrl = CDNEndpoints.APP_ASSET(activity.application_id, activity.assets.small_image);
|
smallUrl = CDNEndpoints.APP_ASSET(activity.application_id, activity.assets.small_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
const game = Games.find((game) => game.id == activity.application_id);
|
if (app?.icon) {
|
||||||
if (game?.icon) {
|
const gameIcon = `${CDNEndpoints.APP_ICON(app.id, app.icon)}&keep_aspect_ratio=false`;
|
||||||
const gameIcon = `${CDNEndpoints.APP_ICON(game.id, game.icon)}&keep_aspect_ratio=false`;
|
|
||||||
image_links.push({label: "App Icon", url: gameIcon});
|
image_links.push({label: "App Icon", url: gameIcon});
|
||||||
|
|
||||||
const largeImage = await fetch(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) {
|
if (activity.application_id && !activity.assets?.large_image && !activity.assets?.small_image) {
|
||||||
const game = Games.find((game) => game.id == activity.application_id);
|
if (app?.icon) {
|
||||||
if (game?.icon) {
|
thumbnail = `${CDNEndpoints.APP_ICON(app.id, app.icon)}&keep_aspect_ratio=false`;
|
||||||
thumbnail = `${CDNEndpoints.APP_ICON(game.id, game.icon)}&keep_aspect_ratio=false`;
|
|
||||||
image_links.push({label: "App Icon", url: thumbnail});
|
image_links.push({label: "App Icon", url: thumbnail});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue