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
Favna3mo ago
not with the built in cooldown. You will have to make your own precondition.
Youssef
YoussefOP3mo 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
YoussefOP3mo ago
No description
Youssef
YoussefOP3mo ago
but that doesnt seem to work
Favna
Favna3mo ago
you should make your own precondition don't try to hack it into the default
Youssef
YoussefOP3mo ago
so like make my own cooldown system ?
Favna
Favna3mo ago
yes
Youssef
YoussefOP3mo ago
thats so dumb why not add the feature
Favna
Favna3mo ago
1. we cant every feature under the sun 2. this is a very niche feature 3. PRs are technically always welcome
Youssef
YoussefOP3mo ago
just a question do you store the cooldown on maps (collections) or in cache ?
Favna
Favna3mo 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
YoussefOP3mo ago
and where i can put the duration of the cooldown?
Youssef
YoussefOP3mo ago
@Boomeravna like how i can do something like this
No description
Favna
Favna3mo 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
YoussefOP3mo ago
No no im not asking for that, my question is just can i add more props to the Command options
No description
Favna
Favna3mo ago
I know what you're asking and I'm telling you to do your own research for a change
Youssef
YoussefOP3mo ago
yeah thanks for the hints, it worked
Youssef
YoussefOP3mo ago
No description
Youssef
YoussefOP3mo 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
Favna3mo 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