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

185
Views
How can I collect a photo submitted by a user?

How can I collect a photo submitted by a user and send it in an embed? I'm using discord.js v13.

I've got the following code but img is not an image URL:

interaction.reply({ content: 'Envia alguna imagen...' }).then(async () => {
  const atch_filter = (m) => !!m.attachments || m.startsWith('https');
  const collected = await interaction.channel.awaitMessages({
    filter: atch_filter,
    max: 1,
  });
  var img = collected.first().url;

  const embed = new MessageEmbed()
    .setTitle('Foto recibida')
    .setImage(img)
    .setColor('BLUE');

  interaction.editReply({ content: 'Listo!', embeds: [embed] });
});
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

awaitMessages returns a collection of messages. Even if it's a single message it's still in a collection. As you set up your filter correctly, the collected message will be collected.first().

Messages have an attachments property, a collection of attachments in the message, so the image will be the first item in the collection; collected.first().attachments.first(). To grab the URL you can use either its url property:

const atch_filter = (m) => !!m.attachments || m.startsWith('https');
const collected = await interaction.channel.awaitMessages({
  filter: atch_filter,
  max: 1,
});
const img = collected.first().attachments.first().url;
about 4 years ago · Juan Pablo Isaza Report

0

Here's what you can try defining image as

let image = collected.attachments.first() ? message.attachments.first().proxyURL : null
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!