Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!