Attaching local file in embed.

So i'm using this code.
const handlers = require("../handlerLoader.js");
const { EmbedBuilder, MessageAttachment } = require("discord.js");
module.exports = {
name: "agree",

async execute(interaction) {
const captcha = handlers.captchaHandler.generateCaptcha();
const captchaEmbed = new EmbedBuilder()
.setColor(0x2B2D31)
.setAuthor({
name: "Captcha Code",
})
.setImage(captcha.filePath)

await interaction.reply({
embeds: [captchaEmbed],
ephemeral: true,
});
},
};
const handlers = require("../handlerLoader.js");
const { EmbedBuilder, MessageAttachment } = require("discord.js");
module.exports = {
name: "agree",

async execute(interaction) {
const captcha = handlers.captchaHandler.generateCaptcha();
const captchaEmbed = new EmbedBuilder()
.setColor(0x2B2D31)
.setAuthor({
name: "Captcha Code",
})
.setImage(captcha.filePath)

await interaction.reply({
embeds: [captchaEmbed],
ephemeral: true,
});
},
};
The variable captcha.filePath like its name hold the file path to a png image. When the button is clicked this error is passed. Could someone advice me on what i'm doing wrong, Does the .setImage only take URL/URIs?
7 Replies
d.js toolkit
d.js toolkit8mo 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! - Marked as resolved by OP
Kiɾʌ Kenjiɾø
I'm currently at work so, Feel free to ping me to grab my attention! <3
d.js docs
d.js docs8mo ago
guide Popular Topics: Embeds - Attaching images > Using the EmbedBuilder read more
Mark
Mark8mo ago
@Kira Kenjiro refer to the guide page here, which has an explanation and examples
Kiɾʌ Kenjiɾø
Sweet, Thanks mark! I'll try just appending the attachment prefix, that might fix it but! Yeh ill try it out :D I no longer get the error anymore! So yay, But it seems as in the discord no image is appearing
Kiɾʌ Kenjiɾø
.setImage(`attachment:/${captcha.filePath}`)
.setImage(`attachment:/${captcha.filePath}`)
that is the snippet i'm using. In the discord it looks like this
No description
Kiɾʌ Kenjiɾø
Nevermind, it's me being an idiot XD You've got to attatch it as a dogeHaHa i never read things correctly okay