I am trying to create a moderation bot and I face a error that shows I don't have commands (Thats my first project). Here is the complete error:
at Object.readdirSync (node:fs:1450:3)
at Object.<anonymous> (C:\Users\artsi\OneDrive\Desktop\goldman bot\src\bot.js:13:6)
at Module._compile (node:internal/modules/cjs/loader:1119:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:18:47 {
errno: -4052, syscall: 'scandir', code: 'ENOTDIR', path: './src/functions/handleCommands.js' }
Here is my bot.js
require("dotenv").config();
const { token } = process.env;
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const fs = require("fs");
const client = new Client({ intents: GatewayIntentBits.Guilds });
client.commands = new Collection();
client.commandArray = [];
const functionFolders = fs.readdirSync(`./src/functions`);
for (const folder of functionFolders) {
const functionFiles = fs
.readdirSync(`.src/functions/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of functionFiles)
require(`./functions${folder}/${file}`)(client);
}
client.handleEvents();
client.handleCommands();
client.login(token);