Cooldowns are per command instead of per user. This means that, if someone uses a command with a 30-second cooldown, that command can not be used by anyone for the next 30 seconds (excluding moderators and above). However, creating commands with cooldowns that work on a per-user basis is possible with the use of Ehsan’s quote system.
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 down and keep them somewhere safe!
I have set up 2 commands below, !command and _!command_helper which work in tandem to output a response depending on whether the user has already recently used the command (only !command is meant to be used directly). Copy and paste the command setups into chat one by one to add the commands, but read the next set of instructions further below before you actually add the commands.
!addcom -cd=5 !command -a=_!command_helper $(eval z=COOLDOWN;d=Date.parse(Date());a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.match(/~$(user)~\d+~/g);`PRIVATE_TOKEN`+(!a||d-parseInt(a[a.length-1].split(`~`)[2])>=z*1000?`&data=~$(user)~${d}~`:``))
!addcom -cd=5 _!command_helper $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;decodeURIComponent(`$(querystring)`).includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`MESSAGE`:`FALLBACK_MESSAGE`):` `)
Further instructions for adding the commands
Feel free to rename !command to whatever command name you want, but do not rename _!command_helper
Locate the following words within the command responses and replace them as instructed below:
COOLDOWN => your desired per-user cooldown in seconds; for example, change this to 86400 for a one-day cooldown
PUBLIC_TOKEN => your public token
PRIVATE_TOKEN => your private token
MESSAGE => what you want Nightbot to respond with
FALLBACK_MESSAGE => what you want Nightbot to respond with if the user has not waited out the cooldown
EDIT 7/9/20: !command is aliased to _!command_helper and is passing information to _!command_helper, specifically your private token and the UTC timestamp at which you used the command, both things that _!command_helper needs to work properly but no one in chat exactly needs to see. Do not use any of the following variables in your message texts: $(touser), $(query), $(querystring)