diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 1afbdd3..adaa754 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -378,7 +378,34 @@ async function processUrl(msg, url) { .then((buf) => Buffer.from(buf)); files.push({ - name: "video." + attachment.type.split("/")[1], + name: attachment.type.replace("/", "."), + contents: file, + }); + } + } + } + if (audios.length > 0) { + for (const attachment of audios) { + const size = await fetch(attachment.url, { + method: "HEAD", + headers: { + "User-Agent": FRIENDLY_USERAGENT, + }, + }) + .then((res) => res.blob()) + .then((blob) => blob.size); + + if (size <= getUploadLimit(msg.channel.guild)) { + const file = await fetch(attachment.url, { + headers: { + "User-Agent": FRIENDLY_USERAGENT, + }, + }) + .then((res) => res.arrayBuffer()) + .then((buf) => Buffer.from(buf)); + + files.push({ + name: attachment.type.replace("/", "."), contents: file, }); }