How I can fill the empty array with attachments url, so I can send them all of them in one message?
Because when I send use url
varaible, same message will be sent several times depending on attachment numbers. This is what I tried so far, but I can't pass through this.. I'm out of ideas.
message.attachments.forEach(attachment => {
const url = attachment.url;
if(url) {
let links = []
Array.from(message.attachments).forEach(links => console.log(links));
const exampleEmbed = new MessageEmbed()
.setColor('#ff0000')
.setAuthor(lastMessage.author.username, message.author.avatarURL({ dynamic: true }))
.setTitle(`(Report)Bug report from ` + lastMessage.author.username + `#` + lastMessage.author.discriminator)
.setURL('https://discord.com/channels/' + lastMessage.guildId + '/' + lastMessage.channelId + '/' + lastMessage.id)
.setDescription(lastMessage.content.replace(/^([^ ]+ ){2}/, '') + ' ' + links);
client.channels.cache.get('ID').send({ embeds: [exampleEmbed] });
}
})
}
}
Problem is I'm unable to fill links array with the urls , so then I can use them in the description, also links
inside of .setDescription
does not provide any value, it's just empty, so it seems that .forEach(links => console.log(links));
doesn't add anything to the let links = []
I was suggested to use this
Array
.from(message.attachments)
.forEach(...);
// Or
[...message.attachments]
.forEach(...);
Trying it with Array.from(message.attachments).forEach
, however I can't figure out how to use it correctly, I'm completely confused from the another examples that I saw(general examples) Every help will be much appreciated..
Log from the Array.from(message.attachments).forEach(links => console.log(links));
[
'924775808831197184',
MessageAttachment {
attachment: 'https://cdn.discordapp.com/attachments/924298360603672576/924775808831197184/bug1.gif',
name: 'bug1.gif',
id: '924775808831197184',
size: 5314,
url: 'https://cdn.discordapp.com/attachments/924298360603672576/924775808831197184/bug1.gif',
proxyURL: 'https://media.discordapp.net/attachments/924298360603672576/924775808831197184/bug1.gif',
height: 128,
width: 128,
contentType: 'image/gif'
}
]
[
'924775809040932945',
MessageAttachment {
attachment: 'https://cdn.discordapp.com/attachments/924298360603672576/924775809040932945/bug.gif',
name: 'bug.gif',
id: '924775809040932945',
size: 5314,
url: 'https://cdn.discordapp.com/attachments/924298360603672576/924775809040932945/bug.gif',
proxyURL: 'https://media.discordapp.net/attachments/924298360603672576/924775809040932945/bug.gif',
height: 128,
width: 128,
contentType: 'image/gif'
}
]
[
'924775808831197184',
MessageAttachment {
attachment: 'https://cdn.discordapp.com/attachments/924298360603672576/924775808831197184/bug1.gif',
name: 'bug1.gif',
id: '924775808831197184',
size: 5314,
url: 'https://cdn.discordapp.com/attachments/924298360603672576/924775808831197184/bug1.gif',
proxyURL: 'https://media.discordapp.net/attachments/924298360603672576/924775808831197184/bug1.gif',
height: 128,
width: 128,
contentType: 'image/gif'
}
]
[
'924775809040932945',
MessageAttachment {
attachment: 'https://cdn.discordapp.com/attachments/924298360603672576/924775809040932945/bug.gif',
name: 'bug.gif',
id: '924775809040932945',
size: 5314,
url: 'https://cdn.discordapp.com/attachments/924298360603672576/924775809040932945/bug.gif',
proxyURL: 'https://media.discordapp.net/attachments/924298360603672576/924775809040932945/bug.gif',
height: 128,
width: 128,
contentType: 'image/gif'
}
]