Is it possible to keep message components active in a loop? How do big bots handle timed out buttons
Let's say I want these button components (moderation actions) to be available as long as they can be, is this possible with a loop of some sort? Whether it is or isn't, how would a popular bot handle it?
7 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 OPIf you want buttons to be available permanently, you shouldn't use a collector, but instead just listen for the custom ID.
So, I would just use interaction create?
also if so, is it possible to create the same event listener (for example, interactionCreate) twice or more? Or is that not good practice
Yes.
Thanks
Well, having two interaction listeners is still alright, but you will use more memory and it's not good if you have listeners all over the place, one is usually enough. At some point it'll even warn you about it, see this page: https://discordjs.guide/popular-topics/errors.html#maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Cool, good to know. Thank you.