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}`)
})
})
CodePudding user response:
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)