How to make an attachment from an http response

I'm making an http request with await fetch(imageUrl) and would like to turn that into an Attachment for use in an embed thumbnail. What is the most efficient way to do that? I'm kinda struggling with streams and buffers.
6 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
DaniDipp
DaniDippOP8mo ago
[email protected] node v20.11.1
monbrey
monbrey8mo ago
Dont even need to fetch it The AttachmentBuilder accepts URLs
DaniDipp
DaniDippOP8mo ago
I can't just put the image url into the embed because the service blocks the discord crawler. I need my bot to download and rebupload it oh
monbrey
monbrey8mo ago
oh Hmm, might still work via attachment though
DaniDipp
DaniDippOP8mo ago
I didn't notice that strings are BufferResolvables, I'll try that Works like a charm, thank you! :robClap:
Want results from more Discord servers?
Add your server