Saturday, 9 May 2020

Unable to find file with fs

Hello, I've been coding my first Discord bot recently and I've been looking at some tutorials so I can have an idea how to structure my code for it to be clean. So I've created a "handler" folder at the root of my project as well as a "commands" folder. The "handler" folder contains a function to load the commands that are in the "commands" folder. The problem is that the bot crash because it's unable to find the directory, I have an error "No such file or directory '../commands/' " but i knoz the folder is there. Does someone has an idea why ? This is the only times i try to access the folder in the code, it's in the js file in the "handler" folderconst commands = fs.readdirSync(`../commands/`).filter(file => file.endsWith('.js')); // Store the files in an array for(let file of commands) { // For each file in commands array let command = require(`../commands/${file}`); // Import the command file

Submitted May 09, 2020 at 09:38PM by Deneguil

No comments:

Post a Comment