Add links-mode embed thumbnails, item metadata, and media filters

This commit is contained in:
Fisto
2026-09-16 11:44:09 +02:00
parent 1fe204b91e
commit 973b9cff92
23 changed files with 863 additions and 82 deletions
+25 -9
View File
@@ -210,16 +210,32 @@ function mapAttachments(message: any) {
}));
}
/** Dimensions of the first embed part that has them: video, image, then thumbnail. */
function embedSize(embed: any) {
for (const part of [embed?.video, embed?.image, embed?.thumbnail]) {
if (part && Number.isFinite(part.width) && Number.isFinite(part.height)) {
return { width: part.width, height: part.height };
}
}
return { width: null, height: null };
}
function mapEmbeds(message: any) {
return (message?.embeds ?? []).map((embed: any) => ({
type: embed?.type ?? null,
url: embed?.url ?? null,
title: embed?.title ?? null,
provider: embed?.provider?.name ?? null,
videoUrl: embedUrl(embed?.video),
imageUrl: embedUrl(embed?.image),
thumbnailUrl: embedUrl(embed?.thumbnail)
}));
return (message?.embeds ?? []).map((embed: any) => {
const size = embedSize(embed);
return {
type: embed?.type ?? null,
url: embed?.url ?? null,
title: embed?.title ?? null,
provider: embed?.provider?.name ?? null,
videoUrl: embedUrl(embed?.video),
imageUrl: embedUrl(embed?.image),
thumbnailUrl: embedUrl(embed?.thumbnail),
width: size.width,
height: size.height
};
});
}
function mapStickers(message: any) {