Discord.js Issues
Go to solution
Solved by Jisagi,
I'm not sure why you put the eventloading inside an async block. Since it's the bot.on function inside that block which fails, it might be a good idea to make this block sync. Then you can also kick promisify. fs.readdir also has a sync version, so it would then look something like shown below. Worth trying I guess.
// Old (async () => { let events = await readdir("./main/events/"); events.forEach(file => { const name = file.slice(0, -3); const event = require(`./main/events/${file}`); //Stole this line as it was so much better than what I had: bot.on(name, event.bind(null, bot)); }); })(); // New const { readdirSync } = require('fs'); let events = readdirSync('./main/events/'); events.forEach(file => { const name = file.slice(0, -3); const event = require(`./main/events/${file}`); bot.on(name, event.bind(null, bot)); });
BTW, you have 2 message event handlers in line 85 and 114. You already use an eventloader structure, so why no moving it there as well?
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now