How can I use image from my assets folder in embed ?

Hi, I would like to create an embed and set the image from my assets folder. I already tried that (with no hopes 😂) :
new EmbedBuilder()
.setTitle('Need help')
.setImage('../assets/my_image.jpg')
new EmbedBuilder()
.setTitle('Need help')
.setImage('../assets/my_image.jpg')
But I receive an error - Discord.js : 14.6.0 - Node : 16.17.0
8 Replies
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs•3y ago
Tag suggestion for @apokalypt: MessageEmbed#attachFiles has been removed. Files should be attached via the message option object instead:
const attachment = new MessageAttachment('./image.png', 'image1.png');
const embed = new MessageEmbed()
- .attachFiles([attachment])
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

- channel.send(embed)
+ channel.send({
+ embeds: [embed],
+ files: [attachment]
+ });
const attachment = new MessageAttachment('./image.png', 'image1.png');
const embed = new MessageEmbed()
- .attachFiles([attachment])
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

- channel.send(embed)
+ channel.send({
+ embeds: [embed],
+ files: [attachment]
+ });
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Apokalypt
ApokalyptOP•3y ago
Alright, thanks WumpsHeartyLove
Apokalypt
ApokalyptOP•3y ago
New error alert 😂
const attachment = new AttachmentBuilder(fs.readFileSync('./assets/my_image.jpg'), { name: 'my_image.jpg'});

const embed = new MessageEmbed()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

await channel.send({ embeds: [embed], attachments: [attachment] });
const attachment = new AttachmentBuilder(fs.readFileSync('./assets/my_image.jpg'), { name: 'my_image.jpg'});

const embed = new MessageEmbed()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

await channel.send({ embeds: [embed], attachments: [attachment] });
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Apokalypt
ApokalyptOP•3y ago
When writing the message I saw the error 😅
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server