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

265
Visualizações
Interaction Channel messages (Discord.js v13)
            let messages = await interaction.channel.messages.fetch();

       messages.then(async (messages) => {
           const output = messages.array().reverse().map(m => `${new Date(m.createdAt).toLocaleString('en-US')} - ${m.author.tag}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`).join('\n');

           console.log(output)
       })

and when I get this console log my console log this error:

    C:\Users\test7\Desktop\ThunderBot\events\bot\slash-interactionCreate.js:195
           messages.then(async (messages) => {
                    ^
    TypeError: messages.then is not a function

interaction.channel data: https://hastebin.com/uwocabepoq.yaml

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are already awaiting the messages. This gives the Collection of messages which does not have the .then method (.then exists on Promise instances, but not unchanged Collection instances). Either remove await to get the Promise instance or run that without the .then

Removing await

let messages = interaction.channel.messages.fetch();
messages.then(async (messages) => {
    const output = messages.array().reverse().map(m => `${new Date(m.createdAt).toLocaleString('en-US')} - ${m.author.tag}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`).join('\n');
    console.log(output)
})

Removing .then

let messages = await interaction.channel.messages.fetch();
const output = messages.array().reverse().map(m => `${new Date(m.createdAt).toLocaleString('en-US')} - ${m.author.tag}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`).join('\n');
console.log(output)
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