Question - handling interactions

How do you guys handle for example temporary interactions but if the user presses on it again a few hours later it should time out?
Solution:
use an InteractionCollector. Also interactions have a timeout of 15 minutes natively.
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Jump to solution
6 Replies
Solution
Favna
Favna17mo ago
use an InteractionCollector. Also interactions have a timeout of 15 minutes natively.
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Mikkel
MikkelOP17mo ago
Ah okay, yeah I meant I have a button that you can click, I assume that button is there indefinitely unless it's edited Is there a way I could catch interactions that aren't in-use? Or should I avoid interaction handlers if I have temporarily interactions?
Favna
Favna17mo ago
Is there a way I could catch interactions that aren't in-use?
No, people will just get "application did not respond" so yeah you have to edit them out just before the handler expires for example PaginatedMessage from sapphire expires in 15 minutes and the components are edited away after (from the top of my head) 14 minutes and 55 seconds. or it was on onEnd... I don't recall. I think it was onEnd
Mikkel
MikkelOP17mo ago
Ah okay I see, so yeah only edge-cases I guess would be if bot crashes If I ctrl + c the bot would that run the handlers?
Favna
Favna17mo ago
no they would stop
Mateleo
Mateleo10mo ago
@Mikkel Have you done it ? I would love to see an example of an expiration of a button
Want results from more Discord servers?
Add your server