Disable buttons if none were clicked when timer runs out
This is a follow up question to one of my previous posts where I wanted to dynamically disable buttons based on their customId once they were clicked. While I was able to get that to work thanks to the input of the kind souls from this server, I ran into an issue while testing my functions further.
If no buttons are clicked and the timer you set on the collector runs out, then the Collection that is emitted is empty:
Collection(0) [Map] {}
(If you click at least one, or more buttons, then you will get back: Collection(i) [Map] {Button Interaction info...}
, with i
being how many buttons you clicked).
I was using the Collection Map to get all the buttons back, so that I could loop over them and disable them individually (I can't just disable the buttons by their name, as I am dynamically creating buttons without a name).
Code for my collector (I am "filtering" on 'collect'):
Code for my collector on 'end' (which works fine as long as at least one button was clicked):
Thanks for the help in advance!
Discord.js: v14.14.1
Node.js: v20.10.02 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!
- ✅
Marked as resolved by OPIt's the original embed I send along with the buttons
Oh? Didn't think of that... Lemme go test that. Thanks for the idea 👍
That ended up solving the issue, thanks for your help! 🍻