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

253
Vistas
Discord.js file error when activating multiple projects

I have a project and I plan to activate more than one bot in this project, but I encountered such a problem while activating my first bot.

Discord.js Version: 13.6.0 Node.js Version: v16.13.2

I leave the glitch project link. https://glitch.com/edit/#!/super-winter-oregano

MAİN 1

require('./botlar/botlist2/botlist2.js')

MAİN 2

const { Client, Intents,Collection } = require('discord.js');
const fs = require('fs')
const config = require("./ayarlar.json")
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); 

client.commands = new Collection();

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    client.commands.set(command.name, command);
}

for (const file of eventFiles) {
    const event = require(`./events/${file}`);
    if (event.once) {
        client.once(event.name, (...args) => event.execute(...args, client));
    } else {
        client.on(event.name, (...args) => event.execute(...args, client));
    }
}

process.on('unhandledRejection', error => {
    console.error('Unhandled promise rejection:', error);
});

client.login(process.env.token2)

ERROR

node:internal/fs/utils:344
    throw err;
    ^
Error: ENOENT: no such file or directory, scandir './commands'
    at Object.readdirSync (node:fs:1390:3)
at Object.<anonymous> (/app/botlar/botlist2/botlist2.js:8:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/app/index.js:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: './commands'
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is because . matches to /app/botlar due to botlist2.js being executed in the file index.js. So for example you would need to do something like this:

fs.readdirSync('./botlar/botlist2/commands');
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