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

217
Visualizações
Loop to workaround 100 message fetch limit no longer working after 1 day

I created a discord bot yesterday from this post to export fields from embeds and it was working fine but it's not working today. The error I'm getting is TypeError: messages.array is not a function I tried uninstalling node and reinstalling but to no avail. I sent the file to a friend to run and it worked perfectly so it seems to be a problem with my machine. I also tried to run it on my windows server and I did not see any errors but the bot failed at exporting the fields (I don't intend on using my server to run the bot, just used for troubleshooting). Has anyone seen this error before and/or have a solution?

More detailed Error (One message):

"xxxx@xxxx-mbp embed bot % node main /Users/xxxx/Downloads/embed bot/main.js:24 sum_messages.push(...messages.array()); ^

TypeError: messages.array is not a function at lots_of_messages_getter (/Users/xxxx/Downloads/embed bot/main.js:24:39) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Client. (/Users/xxxx/Downloads/embed bot/main.js:36:20)"

async function lots_of_messages_getter(channel, limit = 10000) {
const sum_messages = [];
let last_id;

while (true) {
    const options = { limit: 100 };
    if (last_id) {
        options.before = last_id;
    }

    const messages = await channel.messages.fetch(options);
    sum_messages.push(...messages.array());
    last_id = messages.last().id;

    if (messages.size != 100 || sum_messages >= limit) {
        break;
    }
}

return sum_messages;

}

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

0

Messages is a Collection, there is no array method for that object.

According to the documentation you can convert it to a regular array and then use the spread operator.

sum_messages.push(...Array.from(messages));
about 4 years ago · Juan Pablo Isaza Relatório

0

I changed “array” to “values” and it works perfectly now. Thanks to everyone that helped!

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