Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!