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

221
Views
Why do I get channels link instead of attachment?

I'm trying to make a bot. When I type ".test" bot waits for a file. After receiving it, he must send me a Discord link from which I can download the same file. But he only refers to the message where I've sent the file.

Before that, I somehow did it and started experimenting something. After that I was unable to get the same result.

There is my code:

module.exports = {
    commands: 'test',
    callback: (message, arguments, text) => {
        const msg_filter = (m) => m.author.id === message.author.id;
        message.channel.awaitMessages({ filter: msg_filter, max: 1, time: 60000})
        .then((collected) => {
            console.log(collected.first())
            console.log(collected.first().attachment)
            console.log(collected.first().url)
            
            console.log("finish")
        }).catch('Error. No respond.')
    }
}   

Console output:

//First
attachments: Collection(1) [Map] {
    'myId' => MessageAttachment {
      attachment: 'https://cdn.discordapp.com/attachments/914907287603261510/myId/sample.pdf',
      name: 'sample.pdf',
      id: 'myId',
      size: 3028,
      url: 'https://cdn.discordapp.com/attachments/914907287603261510/myId/sample.pdf',
      proxyURL: 'https://media.discordapp.net/attachments/914907287603261510/myId/sample.pdf',
      height: null,
      width: null,
      contentType: 'application/pdf',
      ephemeral: false
    }
  },

//Second
undefined

//Third
https://discord.com/channels/901476184532062209/914907287603261510/917789424857780224
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

collected is a collection that contains every message that got caught by channel.awaitMessages(), so collected.first() is a message. To access this message's attachments, which is a collection, you would need to do collected.first().attachments (beware of the plural). With this in mind, you can manage every attachment in a for-each loop, or just get the first attachment via collected.first().attachments.first()

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!