✨ message attachments
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ export async function handleMessage(opts: Partial<Message>) {
|
||||
mention_channels_ids: [],
|
||||
mention_role_ids: [],
|
||||
mention_user_ids: [],
|
||||
attachments: [], // TODO: message attachments
|
||||
attachments: opts.attachments || [], // TODO: message attachments
|
||||
embeds: opts.embeds || [],
|
||||
reactions: opts.reactions || [],
|
||||
type: opts.type ?? 0
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Config } from "@fosscord/server-util";
|
||||
import FormData from "form-data";
|
||||
import fetch from "node-fetch";
|
||||
|
||||
export async function uploadFile(path: string, file: Express.Multer.File) {
|
||||
const form = new FormData();
|
||||
form.append("file", file.buffer, {
|
||||
contentType: file.mimetype,
|
||||
filename: file.originalname
|
||||
});
|
||||
|
||||
const response = await fetch(`${Config.get().cdn.endpoint || "http://localhost:3003"}${path}`, {
|
||||
headers: {
|
||||
signature: Config.get().security.requestSignature,
|
||||
...form.getHeaders()
|
||||
},
|
||||
method: "POST",
|
||||
body: form
|
||||
});
|
||||
const result = await response.json();
|
||||
|
||||
if (response.status !== 200) throw result;
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user