presence: game icon large image fallback (client behavior)
This commit is contained in:
parent
9d0ce017a9
commit
4f5eae6dcb
1 changed files with 29 additions and 1 deletions
|
@ -316,7 +316,35 @@ presence.callback = async function (msg, line) {
|
|||
smallUrl = CDNEndpoints.APP_ASSET(activity.application_id, activity.assets.small_image);
|
||||
}
|
||||
|
||||
thumbnail = fixMediaProxyURL(smallUrl);
|
||||
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`;
|
||||
image_links.push({label: "App Icon", url: gameIcon});
|
||||
|
||||
const largeImage = await fetch(gameIcon)
|
||||
.then((res) => res.arrayBuffer())
|
||||
.then((b) => Buffer.from(b));
|
||||
const presenceImage = sharp(largeImage).resize(100, 100);
|
||||
const smallImage = await fetch(smallUrl)
|
||||
.then((res) => res.arrayBuffer())
|
||||
.then((b) => Buffer.from(b));
|
||||
const smallImageBuffer = await sharp(smallImage).resize(32, 32).toBuffer();
|
||||
|
||||
presenceImage.composite([
|
||||
{
|
||||
input: smallImageBuffer,
|
||||
gravity: "southeast",
|
||||
},
|
||||
]);
|
||||
|
||||
files.push({
|
||||
contents: await presenceImage.toBuffer(),
|
||||
name: `${index}.png`,
|
||||
});
|
||||
thumbnail = `attachment://${index}.png`;
|
||||
} else {
|
||||
thumbnail = fixMediaProxyURL(smallUrl);
|
||||
}
|
||||
image_links.push({label: "Small Image", url: thumbnail});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue