async function createFormMessage(options = {}) { console.log(options) const form = new FormData(); form.append("content", options.content); form.append("nonce", makeid(12)); form.append("tts", options.tts.toString()); form.append("file", await getBuf(options.attachments?.file), options.attachments.name || "file"); form.append("payload_json", JSON.stringify({ "embed": options.embeds, "message_reference": { message_id: options.reference || null }, }), { contentType: "application/json" }); return { headers: { "Content-Type": "multipart/form-data" }, body: form.getHeaders() }; } // What options is { content: 'Pong', tts: true, attachments: { file: 'https://tenor.com/view/sad-cute-anime-pillow-hugs-gif-17231623', name: 'file.gif' }, embeds: { title: 'Ping?', description: 'Pong!' }, reference: '810735104435421194' } // getBuff const fetch = require("node-fetch"), fs = require("fs"); module.exports = { getBuf: async function (path) { var buf; if (path.startsWith("http")) { const response = await fetch(path), content = response.headers.get("content-type"); if (content && content.startsWith("image/")) { buf = response.buffer(); } } else if (fs.existsSync(path)) buf = fs.readFileSync(path); return buf; } }