actually fix files -> attachments
This commit is contained in:
parent
2dd510030d
commit
8181bb510e
3 changed files with 26 additions and 10 deletions
|
@ -142,15 +142,31 @@ async function CommandDispatcher(msg) {
|
|||
if (response.file) {
|
||||
const newFile = response.file;
|
||||
delete response.file;
|
||||
newFile.contents = newFile.file;
|
||||
delete newFile.file;
|
||||
const files = response.files ?? [];
|
||||
if (newFile.contents) {
|
||||
newFile.file = newFile.contents;
|
||||
delete newFile.contents;
|
||||
}
|
||||
if (newFile.name) {
|
||||
newFile.filename = newFile.name;
|
||||
delete newFile.name;
|
||||
}
|
||||
const files = response.attachments ?? [];
|
||||
files.push(newFile);
|
||||
response.files = files;
|
||||
response.attachments = files;
|
||||
}
|
||||
if (response.files) {
|
||||
response.attachments = response.files;
|
||||
delete response.files;
|
||||
for (const attachment of response.attachments) {
|
||||
if (attachment.contents) {
|
||||
attachment.file = attachment.contents;
|
||||
delete attachment.contents;
|
||||
}
|
||||
if (attachment.name) {
|
||||
attachment.filename = attachment.name;
|
||||
delete attachment.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.embed) {
|
||||
response.embeds = [...(response.embeds ?? []), response.embed];
|
||||
|
|
|
@ -466,14 +466,14 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
.then((buf) => Buffer.from(buf));
|
||||
|
||||
files.push({
|
||||
name:
|
||||
filename:
|
||||
(cw != "" || spoiler ? "SPOILER_" : "") +
|
||||
(attachment.type.indexOf("/") > -1
|
||||
? attachment.type.replace("/", ".")
|
||||
: attachment.type +
|
||||
"." +
|
||||
(url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp4")),
|
||||
contents: file,
|
||||
file,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
.then((buf) => Buffer.from(buf));
|
||||
|
||||
files.push({
|
||||
name:
|
||||
filename:
|
||||
(cw != "" || spoiler ? "SPOILER_" : "") +
|
||||
(attachment.type.indexOf("/") > -1
|
||||
? attachment.type
|
||||
|
@ -508,7 +508,7 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
: attachment.type +
|
||||
"." +
|
||||
(url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp3")),
|
||||
contents: file,
|
||||
file,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
? `|| ${url} ||`
|
||||
: "",
|
||||
embeds,
|
||||
files,
|
||||
attachments: files,
|
||||
allowedMentions: {
|
||||
repliedUser: false,
|
||||
},
|
||||
|
|
|
@ -243,7 +243,7 @@ async function createBoardMessage(msg, count, fetchAttachment = true) {
|
|||
username: msg.member?.displayName ?? msg.author.username,
|
||||
threadID: VINBOARD_THREAD_ID,
|
||||
embeds: [embed],
|
||||
files: image?.file ? [{contents: image.file, name: "thumb.jpg"}] : null,
|
||||
attachments: image?.file ? [{file: image.file, filename: "thumb.jpg"}] : null,
|
||||
wait: true,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue