client is not defined in interactionCreate.js, but it is defined in main.js

If im not wrong, i dont have to defind it again ;=;
72 Replies
d.js toolkit
d.js toolkit15mo 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.
Syjalo
Syjalo15mo ago
I thank your cooldown system should be inside your interactionCreate listener
Suspicious Man
Suspicious Man15mo ago
well, it is its in interactionCreate but i cant start main.js
treble/luna
treble/luna15mo ago
it is not, you destructure it from client, but you never declare client outside of your execute loop so destructure inside your execute loop, and destructure from interaction.client
Suspicious Man
Suspicious Man15mo ago
so, i just have to put it in main.js if im getting you right ?
treble/luna
treble/luna15mo ago
no destructure inside your interactionCreate loop You can leave client.cooldowns defined in your main file But you have to access it from the client in your execute loop
Suspicious Man
Suspicious Man15mo ago
Agh, i dont know how to explain, the only thing in main.js is client.cooldowns, the rest of stuff is in interactionCreate
treble/luna
treble/luna15mo ago
You can do the cooldown logic in your main.js yes, but you cant magically destructure it from a nonexistent property
Suspicious Man
Suspicious Man15mo ago
Well, i just did all like the guide says, i put client.cooldowns = new Collection(); in main.js and other stuff i put in interactionCreate.js I cant put it in there, bc its already there
duck
duck15mo ago
the idea is you can't just put it in the file interactionCreate.js it's not just the code's presence in the file that makes it execute when the event is received the execute function is what executes when the event is received the erroring code is currently outside this function currently it will also presumably execute immediately before the bot even logs in
Suspicious Man
Suspicious Man15mo ago
so, uhh, what should i do ? i have to make it start along with the bot or what ?
duck
duck15mo ago
no, you need to move the code for handling command cooldowns where you actually handle commands: inside the execute function
Suspicious Man
Suspicious Man15mo ago
so, i have to put some part of code into main.js, the file i execute ? right ?
duck
duck15mo ago
no
Suspicious Man
Suspicious Man15mo ago
a
Want results from more Discord servers?
Add your server