Revert "feat(rest/request_manager): support for multiple attachments (#484)" (#498)

This reverts commit 34ce39697a.
This commit is contained in:
ayntee
2021-02-01 13:25:47 +04:00
committed by GitHub
parent 8ab42a6b95
commit e1bc686a66
2 changed files with 3 additions and 21 deletions
+2 -15
View File
@@ -1,10 +1,5 @@
import { authorization, eventHandlers } from "../bot.ts";
import {
Errors,
FileContent,
HttpResponseCode,
RequestMethods,
} from "../types/mod.ts";
import { Errors, HttpResponseCode, RequestMethods } from "../types/mod.ts";
import {
API_VERSION,
BASE_URL,
@@ -160,16 +155,8 @@ function createRequestBody(body: any, method: RequestMethods) {
}
if (body?.file) {
if (!Array.isArray(body.file)) body.file = [body.file];
const form = new FormData();
// form.append("file", body.file.blob, body.file.name);
body.file.map((file: FileContent, index: number) =>
// The key of the form data item must be unique; otherwise, Discordeno only considers the first item in the form data with the same names.
form.append(`file${index + 1}`, file.blob, file.name)
);
form.append("file", body.file.blob, body.file.name);
form.append("payload_json", JSON.stringify({ ...body, file: undefined }));
body.file = form;
} else if (