foxwells.vinboard: more attachment fixes

This commit is contained in:
Cynthia Foxwell 2022-12-02 23:27:42 -07:00
parent 0a2e30a41f
commit 1ed011d9c0

View file

@ -191,20 +191,20 @@ async function findSuitableImage(msg) {
.then((res) => res.arrayBuffer()) .then((res) => res.arrayBuffer())
.then((buf) => Buffer.from(buf)); .then((buf) => Buffer.from(buf));
} }
} } else {
for (const embed of msg.embeds) {
for (const embed of msg.embeds) { if (!embed.url) continue;
if (!embed.url) continue; if (embed.image) {
if (embed.image) { out.url = embed.image.url;
out.url = embed.image.url; break;
break; } else if (embed.video) {
} else if (embed.video) { out.video = true;
out.video = true; out.url = "attachment://thumb.jpg";
out.url = "attachment://thumb.jpg"; out.file = await fetch(embed.video.proxyURL + "?format=jpeg")
out.file = await fetch(embed.video.proxyURL + "?format=jpeg") .then((res) => res.arrayBuffer())
.then((res) => res.arrayBuffer()) .then((buf) => Buffer.from(buf));
.then((buf) => Buffer.from(buf)); break;
break; }
} }
} }
@ -244,7 +244,7 @@ async function createBoardMessage(msg, count) {
threadID: VINBOARD_THREAD_ID, threadID: VINBOARD_THREAD_ID,
threadName: "Vinboard", threadName: "Vinboard",
embeds: [embed], embeds: [embed],
attachments: image.file ? {file: image.file, filename: "thumb.jpg"} : null, files: image.file ? [{file: image.file, filename: "thumb.jpg"}] : null,
}; };
} }