Comments (2)
Thank you @almostSouji
This works:
var img = await Jimp.read('https://i.imgur.com/wSTFkRM.png');
var imgBuf = await img.getBufferAsync(Jimp.AUTO);
const exampleEmbed = new Discord.RichEmbed()
.setTitle('important title')
.setDescription('meaningful description')
.attachFiles([{name: "image.png", attachment:imgBuf}])
.setImage('attachment://image.png');
discordChannel.send(exampleEmbed);
However this doesn't work if you don't use '.png' at the end of 'file' name and it also should not just give a crooked output if used incorrectly.
Re redundancy - I think you missed my point, my code snippet is just using a file but the point is to illustrate work with a local buffer. In real life application one might not have a file.
I did see the warnings and I googled far and deep and did try every possible combination I could think of before opening this issue, so I think you might need to update the code or at least add an example of working with buffer here: https://discordjs.guide/popular-topics/embeds.html#using-the-richembed-constructor
otherwise it seems like really hard to discover. Thanks again for your prompt reply and giving a hint that finally solved my issue
from guide.
As you can see here attachFiles takes an array of FileOptions which may include a name and the attachment itself.
Naming the file then allows you to properly reference it from the setImage
method, which I hoped the yellow warnings all over the guide would suggest.
There's also quite some redundancy in your snippet as you can directly provide an URL as buffer to above mentioned attachment property.
If you have the image on imgur anyways reattaching it is however not even needed as you can simply set embed images to an URL directly.
Edit: If you require more information/help with the approach please visit the Discord server: https://discord.gg/bRCvFy9
from guide.
Related Issues (20)
- How to open a modal when user join server
- Do not defer in filters
- Verification question
- MessageId changing when message is sent? HOT 1
- Deploy Command.js Fails
- <t: :R> tag in cooldowns section. HOT 3
- Incorrect documentation, Modals on Guide.
- guide-event-handling-interactionCreate.js HOT 5
- Duplicate file HOT 3
- Edit Cooldowns page in event that an Event handler was made. HOT 4
- v14 Deploy Commands code not working
- Unclear documentation - what does 'target' mean HOT 2
- Let's comfortably reach more communities HOT 1
- Use glob instead of fs HOT 1
- Reloading Commands has a code snippet that doesn't match the explanation
- Question
- Can bot send voice (aka audio) messages as users can send in mobile app?
- tutorial ES6 update HOT 3
- Timeouts HOT 1
- Sequential Steps HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guide.