Program can't locate file.

viewCaptcha.js
const handlers = require("../handlerLoader.js");
const { EmbedBuilder, AttachmentBuilder } = require("discord.js");
module.exports = {
name: "agree",

async execute(interaction) {
const captcha = await handlers.captchaHandler.generateCaptcha();
const file = new AttachmentBuilder(captcha.filePath, { name: 'captcha.png' });
const captchaEmbed = new EmbedBuilder()
.setColor(0x2B2D31)
.setAuthor({
name: "Captcha Code",
})
.setImage(`attachment://${file.name}`)

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

async execute(interaction) {
const captcha = await handlers.captchaHandler.generateCaptcha();
const file = new AttachmentBuilder(captcha.filePath, { name: 'captcha.png' });
const captchaEmbed = new EmbedBuilder()
.setColor(0x2B2D31)
.setAuthor({
name: "Captcha Code",
})
.setImage(`attachment://${file.name}`)

await interaction.reply({
embeds: [captchaEmbed],
files: [file],
ephemeral: true,
});
},
};
This code, Well.. It works fine but, It can't seem to actually find the file at the file path as it logs this error. I've also attached an image of the file path with the files existing. Could anyone lend me a hand figuring out why this isn't working
No description
No description
35 Replies
d.js toolkit
d.js toolkit15mo 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
Harnes
Harnes15mo ago
Show your whole folders structure
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
Let me grab a screenshot for you
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
No description
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
It's passed as a full directory not a relative
souji
souji15mo ago
navigate into the captchas folder and run pwd i have an idea, but that'll confirm it
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
On it! reddragonSalute
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
No description
souji
souji15mo ago
Hmm
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
HMM
souji
souji15mo ago
it tries to read that, but it isn't there, but it is there what and this is running on that system? not in some container, etc? also what is the full stacktrace of that error
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
Nope, straight in system There is none, That is the error xD
souji
souji15mo ago
yeah, nah, then you're doing nonsense
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
it's not very helpful
souji
souji15mo ago
if you actually log the full error and do not stringify it you get more from it
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
OH WAIT dogeHaHa welp.. look at me bein stoopid again let me go change tht
d.js docs
d.js docs15mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
souji
souji15mo ago
hm. no. bad tag
d.js docs
d.js docs15mo ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
souji
souji15mo ago
closer still not it
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
XD you'll get it eventually <3
souji
souji15mo ago
ignore that, just console.log(error) or console.dir(error, {depth: null}) if you want ALL of it
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
I changed it and the full stack is this
[Error: ENOENT: no such file or directory, stat '/Users/kirakenjiro/Desktop/Coding/DiscordBotBoilerPlate/handlers/captchas/captcha_6.png'] {
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/Users/kirakenjiro/Desktop/Coding/DiscordBotBoilerPlate/handlers/captchas/captcha_6.png'
}
[27-10-2023_15-35-37] • An error has occurred: Error: ENOENT: no such file or directory, stat '/Users/kirakenjiro/Desktop/Coding/DiscordBotBoilerPlate/handlers/captchas/captcha_6.png'
[Error: ENOENT: no such file or directory, stat '/Users/kirakenjiro/Desktop/Coding/DiscordBotBoilerPlate/handlers/captchas/captcha_6.png'] {
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/Users/kirakenjiro/Desktop/Coding/DiscordBotBoilerPlate/handlers/captchas/captcha_6.png'
}
[27-10-2023_15-35-37] • An error has occurred: Error: ENOENT: no such file or directory, stat '/Users/kirakenjiro/Desktop/Coding/DiscordBotBoilerPlate/handlers/captchas/captcha_6.png'
I hope that helps Catting
souji
souji15mo ago
that should still have more, like a reference to the part that tries to read the file in the first place confusedBecel should be node ENOENT: no such file or directory in here usually means someone is confusing readdir with require using relative imports, one reads from cwd one reads from the file itself but you provide a full path
souji
souji15mo ago
unless i am blind, these two are also the same
No description
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
Those two are the same correct <a:kitty_spin:1044167622746439710> I'm passing it the full path
souji
souji15mo ago
do you have some weird character in one of the file names or sth? that's all i can think of
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
No description
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
boop das all
souji
souji15mo ago
can you paste, not screenshot me the output of ls -la in that captchas folder
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
No description
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
shit that is a fair point.. do you want me to grab and send the code here? Because that is genuinely a fair point i'll take a look at it and try await it but, if i need help (I probably will so dont get your hopes up <3) i'll nudge ^^
souji
souji15mo ago
oh it WRITES that one dynamically, yeaah, that aint a thing when that tries to read it then
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
catJAMCRY i forgor to write it with await
No description
Kiɾʌ Kenjiɾø
Kiɾʌ KenjiɾøOP15mo ago
XD shit works :> Thanks you two reddragonLove
Want results from more Discord servers?
Add your server