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
- 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[email protected]
node v20.11.1
Dont even need to fetch it
The AttachmentBuilder accepts URLs
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
oh
Hmm, might still work via attachment though
I didn't notice that strings are BufferResolvables, I'll try that
Works like a charm, thank you! :robClap: