I am getting random undefined errors? something is wrong with discord.js

I need some help with this.
12 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
pierce
pierce12mo ago
─ discord.js@14.11.0 client.once(event.name, (...args) => event.execute(...args, client)); ^ TypeError: Cannot read properties of undefined (reading 'once')
pierce
pierce12mo ago
pierce
pierce12mo ago
I literally have had this code forever inside my bot and now it started erroring out for no reason like what
pierce
pierce12mo ago
pierce
pierce12mo ago
I made a new bot just to test this theory and error out and i was correct it just errors out for no reason
It's Manny
It's Manny12mo ago
What's your event file look like?
pierce
pierce12mo ago
dont have an event file i have a file in events/client/ready.js
pierce
pierce12mo ago
pierce
pierce12mo ago
Well i thought so, since i have used this eventhandler code for eternity, copied everything for it and made a new folder bot to see if the error was with something in my main bot
chewie 🌈
chewie 🌈12mo ago
You never passed client to the loadEvents method, so of course you get that error.
pierce
pierce12mo ago
client.login(client.config.token).then(() => { loadEvents(); }); Ok you guys are right my bad, I just got a bit confused since this "undefined error" keeps happening lol. I've had like 3-4 errors popup from code i've coded so long ago made me think something wrong today loadEvents(client); yes eh, sure Thanks btw i missed the question mark at the end of discord.js? i didnt make an statement taht something was wrong i was asking sry if it came out a bit yk Alright anyways, I will come back here if i get some more undefined errors popup true