Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda