Add an image buffer as an attachment to an embed
discordjs 14.6.0, nodejs 18.15.0
I'm trying to use a buffer to attach an image to an embed, and I have no clue how I'm supposed to do it. I keep getting different errors, and I might just be an idiot, but the docs don't provide any insight into how I should do this either. The buffer, embed and message aren't the problem. I can save the image to a file or edit the embed into the message without adding the image.
Parts of the error that might be relevant:
validator: 's.nullish',
given: 'attachment://SPOILER_Example Name.png'
...
constraint: 's.string.url',
given: 'attachment://SPOILER_Example Name.png',
expected: 'expected to match an URL'
It appears the url is rejected, but I don't really know what url to provide other than the attachment name. Am I doing something obvious wrong?
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 OPFull error
You need to remove the spaces in the file name or else it will throw an error about it being an invalid URL, also update d.js to 14.14.1 as that is a really old version by now.
I haven't worked on this bot for a while, but yes I'll update it soon(ish)
I had just thought of removing the spaces and that did do the trick... sadly now it still displays outside of the embed 😅
I got it working! There must've been some other character in the actual filename that Discord or djs didn't like 🤷♂️, changing it to test.png worked
Just removing the whitespace weirdly enough still had it displayed outside of the embed
sadly now it still displays outside of the embedit should still display inside embed unless thats a Discord bug.
I guess so? After I removed the spaces the error was gone, but it still wasn't displaying correctly.
Anyhow, it works now and I'll just go with a one word filename. Thanks for your help!