so basically, I have followed a video (from IGP) on how to make a command handler for a bot. and I can't figure out why it doesn't work (Tomfoolery is the folder for commands)
client.commands = new Collection();
const commands = fs.readdirSync("./Tomfoolery/").filter(file => file.endsWith(".js"))
for(file of commands) {
const commandName = file.split(".")[0]
const command = require('./Tomfoolery/'+commandName)
client.commands.set(commandName, command)
}
I tried npm rebuild node-sass and npm rebuild node-sass --force and similar stuff, and it still gives me:
Error: ENOENT: no such file or directory, scandir './Tomfoolery/' (even though Tomfoolery IS on the same folder as the bot.js file)
Make sure you are accessing the correct path and prepending the path with __dirname will fix the issue
client.commands = new Collection();
const commands = fs.readdirSync(__dirname+"/Tomfoolery/").filter(file => file.endsWith(".js"))
for(file of commands) {
const commandName = file.split(".")[0]
const command = require(__dirname+'/Tomfoolery/'+commandName)
client.commands.set(commandName, command)
}