Anyone knows how to make a collector from a previously ran command disable after running a new cmd?
Anyone knows how to make a collector from a previously ran command disable after running a new command??
So lets say I ran a command and it gave me a button, I can click it with the collector working and its all fine, but If I run another command, the previous collector stops working to prevent abuse and glitches
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!You could define the collector using
let
in the global scope, and reassign it whenever the command is ran
If the variable has already been assigned, you can stop that collector and reassign it to a new collector
If the variable hasn't been assigned yet, you can just assign it like normalthe bot has each command as a different file module, so variables wouldnt work
Any ideas ?
As they said, you can just define a "collectorStatus" variable at the top of your command file and when a command is ran, you check if the value of that variable and just do collector.stop() or whatever its called to end it and reassign the new collector to that variable again