Cooldowns during command execution

Hi all, wondering if there is a way to set a cooldown using with the global cooldown precondition during command execution? Creating a system for transactions, if said transaction goes through I would like the cooldown to be x amount. Otherwise if it fails, I'd like it to be the default value. Not sure if I need to implement a custom system for this or if this can be achieved with the default tools given.
Solution:
You will have to implement a custom system for this leveraging listeners and a cache for the cool down state.
Jump to solution
8 Replies
gitty
gittyOP5mo ago
If you find the time to reply, I'd greatly appreciate you pinging me when responding! :)
Solution
Favna
Favna5mo ago
You will have to implement a custom system for this leveraging listeners and a cache for the cool down state.
gitty
gittyOP5mo ago
Okay, thank you lots! I'll end up doing that then. Any recommendations for a cache?
Favna
Favna5mo ago
A Map, or Collection if you need to additional methods DJS adds. The exact same way that DJS caches things.
gitty
gittyOP5mo ago
Do you have any idea how I could clear these cooldowns from cache?
Favna
Favna5mo ago
MDN Web Docs
Map.prototype.delete() - JavaScript | MDN
The delete() method of Map instances removes the specified element from this map by key.
gitty
gittyOP5mo ago
yeah but do i check every x minute or whats a good practice for this
Favna
Favna5mo ago
there isnt really any standard. You decide for yourself.
Want results from more Discord servers?
Add your server