Canva Image to .setImage()

How can I add a @napi-rs/canvas image to a embed as image in a .setImage function?
7 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
d.js docs
d.js docs12mo ago
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

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

channel.send({
embeds: [embed],
files: [attachment]
});
Black_Wither
Black_WitherOP12mo ago
const resultBuffer = canvas.toBuffer("image/png");

const attachment = new AttachmentBuilder(resultBuffer, {name: "avatars.png"});

const embed = new EmbedBuilder()
.setColor("#ff0000")
.setDescription("*Currently unavailable*")
.setImage(`attachment://${attachment.name}`)
.setFooter(interaction.message.embeds[0].footer)
const resultBuffer = canvas.toBuffer("image/png");

const attachment = new AttachmentBuilder(resultBuffer, {name: "avatars.png"});

const embed = new EmbedBuilder()
.setColor("#ff0000")
.setDescription("*Currently unavailable*")
.setImage(`attachment://${attachment.name}`)
.setFooter(interaction.message.embeds[0].footer)
@arcticwolvinny 🌈 no error and no image Cry
treble/luna
treble/luna12mo ago
and how are you sending the embed
Black_Wither
Black_WitherOP12mo ago
interaction.editReply({ embeds: [embed], components: [row] })
treble/luna
treble/luna12mo ago
read the tag again
Black_Wither
Black_WitherOP12mo ago
🥹 Thank you!
Want results from more Discord servers?
Add your server