Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda