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);
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});
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();
try {
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",
},
]);
presenceImage.composite([
{
input: smallImageBuffer,
gravity: "southeast",
},
]);
files.push({
contents: await presenceImage.toBuffer(),
name: `${index}.png`,
});
thumbnail = `attachment://${index}.png`;
files.push({
contents: await presenceImage.toBuffer(),
name: `${index}.png`,
});
thumbnail = `attachment://${index}.png`;
} catch {
thumbnail = fixMediaProxyURL(smallUrl);
}
} else {
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) {
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`;
thumbnail = `${CDNEndpoints.APP_ICON(game.id, game.icon)}&keep_aspect_ratio=false`;
image_links.push({label: "App Icon", url: thumbnail});
}
}