Reputation: 133
I'm using discord.js and i'm trying to a local image show up in the embed's thumbnail however it doesn't show up at all and the thumbnail is empty without sending any errors
const embed = new Discord.MessageEmbed()
.setAuthor(`${user.tag}\'s profile (${user.id})`, user.avatarURL())
.addField(`Skin`, `${skin2}`)
.addField(`Total Coins`, `${coinicon} ${coins}`)
.addField(`Inventory Items (${amount})`, `${items}`)
.setThumbnail('attachment://red.png')
.setTimestamp()
.setColor('#00ffff')
.setFooter(message.member.user.tag, message.author.avatarURL());
message.channel.send(embed)
the "red.png" is stored like this
i also tried changing the code to
.setThumbnail('attachment://assets//colors//red.png')
but it didn't work either, any help?
Upvotes: 1
Views: 1181
Reputation: 7321
In oder to set attachment://red.png
, you actually need to attach it first.
To do that, create an attachment with the local path + the name of the attachment (which will be used in attachment://
):
const attachment = new Discord.MessageAttachment(
"./path/to/red.png", // <- local image path
"red.png" // <- name for "attachment://"
);
Then attach it using
.attachFiles(attachment)
In your code:
const attachment = new Discord.MessageAttachment("./path/to/red.png", "red.png");
const embed = new Discord.MessageEmbed()
.attachFiles(attachment) // <- add attachment
.setAuthor(`${user.tag}\'s profile (${user.id})`, user.avatarURL())
.addField(`Skin`, `${skin2}`)
.addField(`Total Coins`, `${coinicon} ${coins}`)
.addField(`Inventory Items (${amount})`, `${items}`)
.setThumbnail('attachment://red.png')
.setTimestamp()
.setColor('#00ffff')
.setFooter(message.member.user.tag, message.author.avatarURL());
message.channel.send(embed);
Upvotes: 3
Reputation: 2220
When you use the first code in your post, try to change message.channel.send to:
message.channel.send({
embed,
files: [{
attachment: '../../assets/colors/red.png',
name: 'red.png'
}]
});
Upvotes: 0