set image of embed from local file

title
6 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
⚡AmirhN
⚡AmirhNOP3y ago
i mean from buffer array
d.js docs
d.js docs3y ago
MessageEmbed#attachFiles has been removed. Files should be attached via the message option object instead:
const attachment = new MessageAttachment('./image.png', 'image1.png');
const embed = new MessageEmbed()
- .attachFiles([attachment])
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

- channel.send(embed)
+ channel.send({
+ embeds: [embed],
+ files: [attachment]
+ });
const attachment = new MessageAttachment('./image.png', 'image1.png');
const embed = new MessageEmbed()
- .attachFiles([attachment])
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

- channel.send(embed)
+ channel.send({
+ embeds: [embed],
+ files: [attachment]
+ });
⚡AmirhN
⚡AmirhNOP3y ago
thanks! tried this:
let image = await axios.get(fetchCache[handle[0]].ipfs, {responseType: 'arraybuffer'})
image = Buffer.from(image.data, 'base64');
const attachment = new AttachmentBuilder(image, `${handle[0]}.png`);
let embed = new EmbedBuilder()
.setFooter({text: `Handle Resolver 📘`})
.setDescription(`Found Address for ${handle}!`+
` Last Updated: <t:${fetchCache[handle[0]].time}:R>`+
`\n\n\`${fetchCache[handle[0]].address}\`\n\n`+
`|| sending another message for our mobile friends if they want to copy ||`)
.setColor(`Green`)
.setImage(`attachment://${attachment.name}`)
interaction.editReply({embeds: [embed], components:[row], files: [attachment]});
let image = await axios.get(fetchCache[handle[0]].ipfs, {responseType: 'arraybuffer'})
image = Buffer.from(image.data, 'base64');
const attachment = new AttachmentBuilder(image, `${handle[0]}.png`);
let embed = new EmbedBuilder()
.setFooter({text: `Handle Resolver 📘`})
.setDescription(`Found Address for ${handle}!`+
` Last Updated: <t:${fetchCache[handle[0]].time}:R>`+
`\n\n\`${fetchCache[handle[0]].address}\`\n\n`+
`|| sending another message for our mobile friends if they want to copy ||`)
.setColor(`Green`)
.setImage(`attachment://${attachment.name}`)
interaction.editReply({embeds: [embed], components:[row], files: [attachment]});
but image is being posted outside of the embed const attachment = new AttachmentBuilder(image, {name: ${handle[0]}.png}); like this?
⚡AmirhN
⚡AmirhNOP3y ago
⚡AmirhN
⚡AmirhNOP3y ago
same problem https://github.com/discordjs/guide/issues/242 nvm found problem embed object was trying to get this image:
image: { url: 'attachment://$0227.png' }
image: { url: 'attachment://$0227.png' }
but image was actually 0227.png :D
Want results from more Discord servers?
Add your server