#discord bot

27 messages · Page 1 of 1 (latest)

cinder canopy
#

the error says Error: Cannot find module 'dotenv' and the code is

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/function${folder}`)
    .filter((file) => file.endsWith(".js"));
  for (const file of functionFiles)
    require(`./functions${folder}/${file}`)(client);
}

client.handleEvents();
client.handleCommands();
client.login(token);```
fast galleon
#

npm i dotenv

#

kek

cinder canopy
#

i fixed it thanks but i got another error
const result = binding.readdir(
^

Error: ENOENT: no such file or directory, scandir 'C:\Users\Desktop\bot\src\functions${folder}'

#

errno: -4058,
code: 'ENOENT',
syscall: 'scandir',

fast galleon
#

./src/function${folder} seems to be incorrect

cinder canopy
fast galleon
#

Probably

cinder canopy
# fast galleon Probably

i changed it and it says
Error: ENOENT: no such file or directory, scandir 'C:\Users\Desktop\bot\src\function${folder}'
still an error

fast galleon
#

-> No such file

cinder canopy
fast galleon
#

try printing out the path you're trying to access

cinder canopy
cinder canopy
cinder canopy
#
    .readdirSync("./src/functions/${folder}")
    .filter((file) => file.endsWith(".js"));```
#

im bad at this ik

#

thank you so much

#

i just fixed quotation and it worked

fast galleon
#

Lol I thought your quotations were right

#

sus

cinder canopy
fast galleon
#

Oh yeah those are the correct ones for formatting strings

cinder canopy
#

im new to js and in python and c++ i always used ""

fast galleon
#

It looked like you had those backticks already earlier

cinder canopy
#

ye but i just changed the ones left like "" for `` and its good so