How to get the attachment path?

Hello, I am trying to use an image in an embed but it won't show. The image is in the same folder.
let embed = new EmbedBuilder()
.setTitle('Title')
.setDescription('Description')
.setImage('attachment://screenshot.png')

interaction.editReply({embeds: [embed]})
let embed = new EmbedBuilder()
.setTitle('Title')
.setDescription('Description')
.setImage('attachment://screenshot.png')

interaction.editReply({embeds: [embed]})
How do I set the image properly?
22 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jr
jr3y ago
setImage needs a url to an existing image you'll have to upload the image somewhere first one trick is you can upload it to another channel and then use the discord cdn url
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs3y ago
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 User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
Will the image file be within the embed then?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
Okay, thanks :)
Skuffies
SkuffiesOP3y ago
Image doesn't show up. Code:
const attachment = new AttachmentBuilder('./screenshot.png');

let embed = new EmbedBuilder()
.setTitle('Omxs30')
.setDescription('En bild på Omxs30 senaste dag taget från Avanza.')
.setImage(`attachment://${attachment.name}`);

interaction.editReply({embeds: [embed]});
const attachment = new AttachmentBuilder('./screenshot.png');

let embed = new EmbedBuilder()
.setTitle('Omxs30')
.setDescription('En bild på Omxs30 senaste dag taget från Avanza.')
.setImage(`attachment://${attachment.name}`);

interaction.editReply({embeds: [embed]});
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
I did that but it just sends it with the embed not in it
Skuffies
SkuffiesOP3y ago
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
const attachment = new AttachmentBuilder('./screenshot.png', 'screenshot.png'); like this?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
Thank you! Works great now :D
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
How would I use the buffer? buffer, buffer or
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
That's what I thought, thank you.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Skuffies
SkuffiesOP3y ago
Thank you :)
Want results from more Discord servers?
Add your server