Click here to Skip to main content
15,663,639 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Bot.js code:
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)


const { Events } = require("discord.js");
const fs = require("fs");

module.exports = (client) => {
  client.handleEvents = async () => {
    const eventFolders = fs.readdirSync(`./src/events`);
    for (const folder of eventFolders) {
      const eventFiles = fs
        .filter((file) => file.endsWith(".js"));
      switch (folder) {
        case "client":
            for (const file of eventFiles) {
                const event = require(../../src/Events/${folder}/${file});
                if (event.once) client.once(, (...args) => event.execute(...args, client));
                else client.on(, (...args) => event.execute(...args, client));

> hyperbot@1.0.0 test
> node .

  throw err;

Error: Cannot find module '.src/functions/handlers/handleCommands.js'
Require stack:
- C:\Users\Admin\Desktop\HyperBot\src\bot.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\Users\Admin\Desktop\HyperBot\src\bot.js:15:5)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  requireStack: [ 'C:\\Users\\Admin\\Desktop\\HyperBot\\src\\bot.js' ]

Node.js v18.12.1

What I have tried:

I have tried changing from
const event = require(../../src/Events/${folder}/${file});


const event = require(src/Events/${folder}/${file});
Updated 2-Jan-23 10:13am
Graeme_Grant 2-Jan-23 10:07am    
open a command prompt, navigate to the execution [root] path, then use your path fragment and try to change dir to it...
Chaz O 2-Jan-23 10:10am    
Thanks for the response. Without asking you to spoonfeed - could you please be a little more specific in command?
Graeme_Grant 2-Jan-23 10:13am    
cd [path fragment goes here]

WIN+R > cmd.exe

You do know how to change to the root path for your app right?
Chaz O 2-Jan-23 10:38am    
i understand dos commands i just wasn't sure what you meant by path fragment. Where should i cd to?

changing root path of my app... not off the top of my head, this is my first js bot man. Appreciate your time :)
Graeme_Grant 2-Jan-23 10:40am    
this is the path fragment:
It is not a fully qualified path but is valid from the current path if it points to a valid qualified path.

1 solution

Case-sensitive letter change in ./src/functions
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900