presence: guh

This commit is contained in:
Cynthia Foxwell 2025-05-01 22:01:43 -06:00
parent 4f5eae6dcb
commit e5fef270ad
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk
2 changed files with 10944 additions and 32829 deletions

File diff suppressed because it is too large Load diff

View file

@ -318,30 +318,34 @@ presence.callback = async function (msg, line) {
const game = Games.find((game) => game.id == activity.application_id); const game = Games.find((game) => game.id == activity.application_id);
if (game?.icon) { if (game?.icon) {
const gameIcon = `${CDNEndpoints.APP_ICON(game.id, game.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)
.then((res) => res.arrayBuffer()) .then((res) => res.arrayBuffer())
.then((b) => Buffer.from(b)); .then((b) => Buffer.from(b));
const presenceImage = sharp(largeImage).resize(100, 100); try {
const smallImage = await fetch(smallUrl) const presenceImage = sharp(largeImage).resize(100, 100);
.then((res) => res.arrayBuffer()) const smallImage = await fetch(smallUrl)
.then((b) => Buffer.from(b)); .then((res) => res.arrayBuffer())
const smallImageBuffer = await sharp(smallImage).resize(32, 32).toBuffer(); .then((b) => Buffer.from(b));
const smallImageBuffer = await sharp(smallImage).resize(32, 32).toBuffer();
presenceImage.composite([ presenceImage.composite([
{ {
input: smallImageBuffer, input: smallImageBuffer,
gravity: "southeast", gravity: "southeast",
}, },
]); ]);
files.push({ files.push({
contents: await presenceImage.toBuffer(), contents: await presenceImage.toBuffer(),
name: `${index}.png`, name: `${index}.png`,
}); });
thumbnail = `attachment://${index}.png`; thumbnail = `attachment://${index}.png`;
} catch {
thumbnail = fixMediaProxyURL(smallUrl);
}
} else { } else {
thumbnail = fixMediaProxyURL(smallUrl); thumbnail = fixMediaProxyURL(smallUrl);
} }
@ -352,7 +356,7 @@ 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); const game = Games.find((game) => game.id == activity.application_id);
if (game?.icon) { if (game?.icon) {
thumbnail = `${CDNEndpoints.APP_ICON(game.id, game.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});
} }
} }