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

153
Vistas
Discord.js V13 sending message attachments

After upgrading to discord.js v13 and using Array.from(message.attachments.values()) instead of message.attachments.array() to send attachments from a message,

message.client.channels.cache.get("123456789").send({
    files: [Array.from(message.attachments.values())],
    content: `test`
});

I get an error from the console from the node module:

Desktop\Bot\node_modules\discord.js\src\structures\MessagePayload.js:223
      if (thing.path) {
                ^

TypeError: Cannot read property 'path' of undefined

The part where the error comes is here:

const findName = thing => {
      if (typeof thing === 'string') {
        return Util.basename(thing);
      }

      if (thing.path) {
        return Util.basename(thing.path);
      }

      return 'file.jpg';
    };

I'm really confused on what's wrong or how to fix it, any help?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are creating an array inside of an array, remove the extra square brackets. Array.from() returns a new instance of an Array already.

message.client.channels.cache.get("channel id").send({
    files: Array.from(message.attachments.values()),
    content: `test`
});

Alternatively you could spread the iterable into an array using the spread operator.

message.client.channels.cache.get("channel id").send({
    files: [...message.attachments.values()],
    content: `test`
});
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