Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
User image to Discord Embed

I want the image that a user sends to be fetched and put into an embed that the bot will then send. As the image must be a url and the person sends an image, I don't know how I can transform this image into a url. When doing the command, the embed send but without the image. This is what i've tried but it didn't work :

const plotEmbed = new Discord.MessageEmbed() 
                        .setTitle(`Purchase of the plot n°${plotId}`)
                        .setColor("GREEN")
                        .setDescription(`Purchase of plot ${plotId} for ${days} days.`)
                        .setImage(message.attachments.first.url)
                        .setTimestamp()
message.channel.send({ embeds: [pEmbed]})

If someone could get me an advice on what I should try because I don't really know... Thanks for reading.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Using message.attachments gives a collection, so you can use the .map() command to get the urls. All you have to do is change your code to:

const attachmentURL = message.attachments.map(attachment => attachment.url)
const plotEmbed = new Discord.MessageEmbed()
  .setTitle(`Purchase of the plot n°${plotId}`)
  .setColor("GREEN")
  .setDescription(`Purchase of plot ${plotId} for ${days} days.`)
  .setImage(attachmentURL[0])
  .setTimestamp()
message.channel.send({
  embeds: [pEmbed]
})

This might just be the fact that pEmbed was declared before your code snippet but just wanted to tell that you are sending an embed called pEmbed while the embed in your current code snippet is in a variable called plotEmbed, so you might want to change that.

Edit:

Just found another way which is the simpler one. You just made a mistake calling message.attachments.first. It should actually be message.attachments.first().url because first() is actually a function. So this should also work exactly like the first method I posted

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!