Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
Command Handler's file reading doesn't work

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)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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)
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda