#scandir problem
1 messages · Page 1 of 1 (latest)
I use this ```fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(./events/${file});
let eventName = file.split(".")[0];
bot.on(eventName, event.bind(null, bot));
});
});
what's the error
where is events located
try using fs.readdirSync(path.join(__dirname, "events")
also import path (no instalation needed)
Path?
it doesn't have caps tho
wth have you done
I dont get it xd
i think make the function (err , files)
fs.readdir(path.join("./", "events"), (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
bot.on(eventName, event.bind(null, bot));
});
});
@elfin pawn try this
ok try __dirname instead of "./"
ReferenceError: path is not defined
why didn't import path yet
Const path = require("./events/ready") | TypeError: path.join is not a function
const without caps
Const path = require("./events/") | Error: Cannot find module './events/'
Its without caps, just discord plugin
Ohhh
you need to learn node.js basics
I know them, but i was using methods from older node
But idk why it wants folder name
Discord-bot folder is in folder and it was checking that folder and not where is that script located
try put "./" instead you can reverse if it doesn't work
I did that before
ok ig your problem solved imma archive this thread