Custom Cooldown Command

Asked Jan 3, 2021·6 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hey guys,

I spent all night reading other posts here and still i cant figure out if what i want is possible, maybe because I don't know much about programming...

I want to make a nightbot command that has a global cooldown, not for each user, that goes like this:

!draw would have a 30min cooldown after its last use and when not on cooldown it would say something like: Streamer is ready to draw something!

If !draw is used less than 30min before the last one, it would return the remaining cooldown time on chat.

While it doesn't sound too complex, from what I've been reading here I think I might be way in over my head.

Any tips would be appreciated !

6 replies

Hey @Artful Hamster!

It's not possible to have a cooldown above 5min, unless you're using the Nightbot API, I believe what you're looking for is possible to do with it.

@Polar Cat yeah i figured as much... any tips on how i can learn to make a custom API for this?

@Deft Penguin any thoughts on this? 🤔

Click this link. It will generate three links and two tokens, a public token (8 characters long) and a private token (16 characters long). The public token is located within the first generated link. The private token is located within both the second and third generated links. The tokens are found after token= and before &data=$(querystring). Copy them and keep them somewhere safe!

Copy and paste these into chat to add !draw and !draw (only !draw is to be used directly). Replace `PUBTOKEN with the public token and PRIV_TOKEN` with the private token.

!addcom -cd=5 !draw -a=_!draw $(eval d=Date.parse(Date());a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUB_TOKEN)`.match(/~\d+~/g);p=`PRIV_TOKEN`;if(!a){p+`&data=~${d}~`;}else{b=d-parseInt(a[a.length-1].split(`~`)[1]);p+(b>=1800000?`&data=~${d}~`:`~`+(1800-b/1000));})
!addcom -cd=5 _!draw $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIV_TOKEN`)?(a.includes(`Successfully added entry`)?`$(channel) is ready to draw something!`:b.split(`~`)[1]+` seconds remain.`):` `)

Thank you so much for putting this together :D you're awesome!

I've been tweaking around with it a little and i cant make the correct time appear. it shows me a cooldown of 1.8 million seconds in the original code you made, if i try to change some numbers it always gives me something that doesnt make sense, like negative cooldown or no cooldown at all...

Also, how can i turn it into minutes?

Once again, thank you very much!!

Edit: i just figured out how to get the correct number of seconds, needed to cut three zeros on the second 1800000. Now i only need to know the minute conversion 😃

Yes there's 1800 seconds in 30 minutes; I've edited the code to output the remaining time correctly. Now to show the cooldown in minutes, replace (1800-b/1000) in !draw with (1800-b/1000)/60 and seconds in _!draw with minutes

Didn't find your answer? The community is on Discord.

Ask on Discord