izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

Is it possible to upload a file directly via buffer? #322

Closed conlan closed 4 years ago

conlan commented 4 years ago

Hi there, currently when I use client.uploadFile() with a local file it's inserted directly into the chat:

Screen Shot 2019-10-20 at 2 17 09 PM

But when I use client.uploadFile() with a buffer and (required) filename, it uploads like this:

Screen Shot 2019-10-20 at 2 17 51 PM

Is it possible to use a buffer and have the former result? Or do I need to save the buffer to a local file first and then do that method?

Thanks in advance!

cloudrac3r commented 4 years ago

you need to add .png or .jpg to the filename that you used. discord will only render uploaded images if they have the correct extension in the filename that they were uploaded as.

conlan commented 4 years ago

Ah! Okay thanks :)