ReferenceError: js is not defined

hello i get this error when i try to run my discord bot - ReferenceError: js is not defined

the code that i tried to run it with :

const fs = require(‘fs’);

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync(’./commands’).filter(file => file.endsWith(’.js’));

for (const file of commandFiles) {

const command = require(`./commands/${file}`);



client.commands.set(command.name, command);

}

PS i am new to scripting like i just started yesterday so i am not some kind of professional.

Hi and welcome, SuculetZ :slight_smile:

Does it say what line the error occurs on? I can’t see a line here that would cause that error, as you don’t have a variable called js:thinking:

Check the quote marks around '.js'. They have come through a bit funky here in Discourse but check they are just single apostrophes or speech marks in your original code.

It’s possible your error is happening in a part you’ve not listed above.

Hopefully we can help! :slight_smile:

4 Likes

Oh, i actually tried to change the quotation marks around the js and it works fine now, thank you!

I only opened VSC just to copy the first part of the error, ‘’ [ReferenceError: js is not defined] ‘’ and just quit after that. I can’t copy paste the rest of the error anymore because the message got deleted in the Terminal. (the next time i have a problem i will put the whole code and the error so i can get further help).

Anyway thank you very much for helping me, have a great day! :grinning:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.