Attach files with @discordjs/rest
How do I attach files and send POST it to channel message endpoint properly?
npm list discord.js and node node -v version?attachment variable is raw attachment from discordattachmentconst attachment = ctx.message.attachments.at(0)!;
const img = await got.get(attachment.proxy_url).buffer();
const cache = cast<APIMessage>(await this.container.client.rest.post(Routes.channelMessages(), {
body: {
attachments: [
{
id: 0,
filename: attachment.filename
}
]
},
files: [
{
data: img,
name: attachment.filename,
contentType: attachment.content_type,
key: "0"
}
]
}));