Reputation: 151
I'm trying to collect attachments from a message and then send them in an embed. I've tried this:
attachment = message.attachments.first()
url = attachment.url
const embedmem = new Discord.MessageEmbed()
.setColor('#ffffff')
.setTitle('Title')
.setDescription('Description')
.setImage(url)
message.channel.send(embedmem);
But no images appeared. Please tell me if I'm doing something wrong.
Upvotes: 0
Views: 1456
Reputation: 6645
You should define your variables (such as attachment and URL) using const
/let
/var
etc... (depending on your needs).
const Attachment = message.attachments.first(); // Getting the attachment.
const Embed = new Discord.MessageEmbed() // Creating an embed message.
.setColor("#ffffff")
.setTitle("Title")
.setDescription("Description")
if (Attachment && Attachment.url) {Embed.setImage(Attachment.url)} // If the attachment exists we are adding the image.
message.channel.send(Embed);
Upvotes: 1