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

191
Views
Discord.js Array coming as undefined

The command is taking in an image and some text with it in channel-1 and posting the same image and text in channel-2. The image gets posted but the text comes out as undefined but when i print out the value in the console it is not empty.

Input in channel -1 input in channel 1

Output in channel 2 Output in channel 2

Code

    if(!args.length){
        return message.channel.send(`${message.author} There was no input,Command: ${message} ,your input: ${args}`);
    }
    var str= args.toString();
    const values=str.split(' ');
    client.channels.cache.get("channel-id").send({
        files:Array.from(message.attachments.values()),
        content:`${values[1]}`
    });
    console.log(values);
    client.channels.cache.get("channel-id").send(`here it is --- ${values[1]}`);
} 

Console-

Ready
[ 'hello,world' ] 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think the problem is with your implementation. You are accessing values[1] whereas in the console.log() it appears the values array has only one element i.e at values[0]

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!