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?
No description
7 Replies
d.js toolkit
d.js toolkit8mo ago
- 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 OP
lupus
lupus8mo ago
If you want buttons to be available permanently, you shouldn't use a collector, but instead just listen for the custom ID.
Swyftey
SwyfteyOP8mo ago
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
lupus
lupus8mo ago
Yes.
Swyftey
SwyfteyOP8mo ago
Thanks
lupus
lupus8mo ago
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.
Swyftey
SwyfteyOP8mo ago
Cool, good to know. Thank you.
Want results from more Discord servers?
Add your server