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

157
Views
discord.js - How to get specific collected message

I'm trying to get specific collected message, e.g. third collected message. The forEach works perfect, but I need just one specific, like I said previously.

collector.on('end', collected => {
    console.log(`Collected ${collected.size} messages`)

    message.channel.send(`${collected}`)

    collected.forEach(value => {
      message.channel.send(`${value}`)
    })
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

collected is a Collection, not an array. You can find the documentation here.

You could use the .at(index) method that returns the item at a given index. So in order to get the third item, you could use the following:

let thirdCollectedMessage = collected.at(2)
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!