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

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

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 Denunciar

0

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

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