Searching for a directory that is non-existent

Hello, I keep trying to figure this out but the code is not working and keeps trying to look for a directory thats not made. Error:
Uncaught Error Error: ENOENT: no such file or directory, scandir '(my files)\discord-bot\commands\support\commands\support'
at readdirSync (fs:1527:3)
at <anonymous> ((my files)\discord-bot\commands\support\feedback.js:12:31)
at Module._compile (internal/modules/cjs/loader:1256:14)
at Module._extensions..js (internal/modules/cjs/loader:1310:10)
at Module.load (internal/modules/cjs/loader:1119:32)
at Module._load (internal/modules/cjs/loader:960:12)
at Module.require (internal/modules/cjs/loader:1143:19)
at require (internal/modules/cjs/helpers:119:18)
at <anonymous> ((my files)\discord-bot\deploy-commands.js:18:19)
at Module._compile (internal/modules/cjs/loader:1256:14)
at Module._extensions..js (internal/modules/cjs/loader:1310:10)
at Module.load (internal/modules/cjs/loader:1119:32)
at Module._load (internal/modules/cjs/loader:960:12)
at executeUserEntryPoint (internal/modules/run_main:86:12)
at <anonymous> (internal/main/run_main_module:23:47)
Uncaught Error Error: ENOENT: no such file or directory, scandir '(my files)\discord-bot\commands\support\commands\support'
at readdirSync (fs:1527:3)
at <anonymous> ((my files)\discord-bot\commands\support\feedback.js:12:31)
at Module._compile (internal/modules/cjs/loader:1256:14)
at Module._extensions..js (internal/modules/cjs/loader:1310:10)
at Module.load (internal/modules/cjs/loader:1119:32)
at Module._load (internal/modules/cjs/loader:960:12)
at Module.require (internal/modules/cjs/loader:1143:19)
at require (internal/modules/cjs/helpers:119:18)
at <anonymous> ((my files)\discord-bot\deploy-commands.js:18:19)
at Module._compile (internal/modules/cjs/loader:1256:14)
at Module._extensions..js (internal/modules/cjs/loader:1310:10)
at Module.load (internal/modules/cjs/loader:1119:32)
at Module._load (internal/modules/cjs/loader:960:12)
at executeUserEntryPoint (internal/modules/run_main:86:12)
at <anonymous> (internal/main/run_main_module:23:47)
Code:
const { Client, GatewayIntentBits } = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, token } = require('../../config.json');
const fs = require('fs');
const path = require('path');

const commands = [];

// Collect your custom commands
const customCommandsPath = path.join(__dirname, 'commands/support'); // Corrected path here
const customCommandFiles = fs.readdirSync(customCommandsPath).filter(file => file.endsWith('.js'));

for (const file of customCommandFiles) {
const feedback = require(path.join(customCommandsPath, file));
commands.push(feedback.data.toJSON()); // Push each command to the commands array
}

const rest = new REST({ version: '10' }).setToken(token);

(CUT IT SHORT DUE TO NO SPACE)
const { Client, GatewayIntentBits } = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, token } = require('../../config.json');
const fs = require('fs');
const path = require('path');

const commands = [];

// Collect your custom commands
const customCommandsPath = path.join(__dirname, 'commands/support'); // Corrected path here
const customCommandFiles = fs.readdirSync(customCommandsPath).filter(file => file.endsWith('.js'));

for (const file of customCommandFiles) {
const feedback = require(path.join(customCommandsPath, file));
commands.push(feedback.data.toJSON()); // Push each command to the commands array
}

const rest = new REST({ version: '10' }).setToken(token);

(CUT IT SHORT DUE TO NO SPACE)
3 Replies
d.js toolkit
d.js toolkit14mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Roreos
RoreosOP14mo ago
Im running 14.13.0 and node.js 18.18.0
d.js docs
d.js docs14mo ago
Determining your discord.js version: - npm list discord.js - Make sure you use the right documentation for your installed version (selector on the left)
Want results from more Discord servers?
Add your server