ehz
ehz
DIAdiscord.js - Imagine an app
Created by ehz on 1/2/2025 in #djs-questions
image in embed
I'm working on something and I'm genuinely confused why this doesn't work. I've looked at previous questions about it but none of it works for me. I've tried both with EmbedBuilder and embed object, but both dont work
const image = await generateRankCard(playerData);
console.log(image);

const embed = new EmbedBuilder()
.setTitle(`${interaction.user.username}'s rank`)
.setImage(`attachment://${image.url}`);

const embedObject = {
title: `${interaction.user.username}'s rank`,
image: {
url: `attachment://${image.url}`,
},
};
return interaction.editReply({ embeds: [embedObject] }); // files: [image]
const image = await generateRankCard(playerData);
console.log(image);

const embed = new EmbedBuilder()
.setTitle(`${interaction.user.username}'s rank`)
.setImage(`attachment://${image.url}`);

const embedObject = {
title: `${interaction.user.username}'s rank`,
image: {
url: `attachment://${image.url}`,
},
};
return interaction.editReply({ embeds: [embedObject] }); // files: [image]
the image is made with the AttachmentBuilder and canvas:
const attachment = new AttachmentBuilder(canvas.toBuffer("image/png"), {
name: "rank-card.png",
});
const attachment = new AttachmentBuilder(canvas.toBuffer("image/png"), {
name: "rank-card.png",
});
as you can probably tell, I've tried sending the image as file, and that does work and show the image. this is what the console.log(image) shows;
AttachmentBuilder {
attachment: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 03 20 00 00 01 c2 08 06 00 00 00 17 63 ad c8 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 04 ... 40080 more bytes>,
name: 'rank-card.png',
description: undefined
}
AttachmentBuilder {
attachment: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 03 20 00 00 01 c2 08 06 00 00 00 17 63 ad c8 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 04 ... 40080 more bytes>,
name: 'rank-card.png',
description: undefined
}
could anyone possibly help me?
14 replies