Coodown

Can i reset the cooldown for a specific command for a specific user?
Solution:
not with the built in cooldown. You will have to make your own precondition.
Jump to solution
21 Replies
Solution
Favna
Favna2mo ago
not with the built in cooldown. You will have to make your own precondition.
Youssef
Youssef2mo ago
i tried to do something like this
const command = this.container.stores
.get("commands")
.find((c) => c.name == "drop");
if (!command) return;

type CooldownPreconditionInstance =
(typeof CorePreconditions)["Cooldown"]["prototype"];

(
this.container.stores
.get("preconditions")
.get("Cooldown") as CooldownPreconditionInstance
).buckets
.get(command)
?.set(user.id, { remaining: 0 });
const command = this.container.stores
.get("commands")
.find((c) => c.name == "drop");
if (!command) return;

type CooldownPreconditionInstance =
(typeof CorePreconditions)["Cooldown"]["prototype"];

(
this.container.stores
.get("preconditions")
.get("Cooldown") as CooldownPreconditionInstance
).buckets
.get(command)
?.set(user.id, { remaining: 0 });
Youssef
Youssef2mo ago
No description
Youssef
Youssef2mo ago
but that doesnt seem to work
Favna
Favna2mo ago
you should make your own precondition don't try to hack it into the default
Youssef
Youssef2mo ago
so like make my own cooldown system ?
Favna
Favna2mo ago
yes
Youssef
Youssef2mo ago
thats so dumb why not add the feature
Favna
Favna2mo ago
1. we cant every feature under the sun 2. this is a very niche feature 3. PRs are technically always welcome
Youssef
Youssef2mo ago
just a question do you store the cooldown on maps (collections) or in cache ?
Favna
Favna2mo ago
GitHub
framework/src/preconditions/Cooldown.ts at main · sapphiredev/frame...
Discord bot framework built on top of discord.js for advanced and amazing bots. - sapphiredev/framework
GitHub
utilities/packages/ratelimits/src/lib/RateLimitManager.ts at main ·...
Common JavaScript utilities for Sapphire Projects. Contribute to sapphiredev/utilities development by creating an account on GitHub.
Youssef
Youssef2mo ago
and where i can put the duration of the cooldown?
Youssef
Youssef2mo ago
@Boomeravna like how i can do something like this
No description
Favna
Favna2mo ago
please, all you need to do is dig through the sapphire framework code. I, just like anyone else, doesn't like spoon feeding you the code. try to do your own research for a change
Youssef
Youssef2mo ago
No no im not asking for that, my question is just can i add more props to the Command options
No description
Favna
Favna2mo ago
I know what you're asking and I'm telling you to do your own research for a change
Youssef
Youssef2mo ago
yeah thanks for the hints, it worked
Youssef
Youssef2mo ago
No description
Youssef
Youssef2mo ago
@Boomeravna Sorry, just a question can't i name the precondition as "Cooldown" ? because when i name it Cooldown it doesnt apear even with the typescript augmentation
Favna
Favna2mo ago
Sapphire Framework
Creating your own preconditions | Sapphire
Just as we did in Creating Commands, we will start by creating a preconditions subdirectory in
Want results from more Discord servers?
Add your server