So i have been trying to fix this issue for a while now and even rewrote some bits but so far it still keeps giving the same thing... Below is the code and the terminal output This is done using node.js and discord.js
Main Bot Code
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.color = "";
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);
The Terminal Output
C:\Users\Maheel\Desktop\NewTestingBOt\src\bot.js:17
require(`./functions/${folder}/${file}`)(client);
^
TypeError: require(...) is not a function
at Object.<anonymous> (C:\Users\Maheel\Desktop\NewTestingBOt\src\bot.js:17:45)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Thanks in advance to those who help with this error message