NightDev Community Forums

Timer for !game

Hi, i want to create a command what says “@xxxxx is playing … 2 hours and 27 minutes ago” is this possible?

1 Like

What exacly are you asking for? Do you mean uptime for the entire stream. Or do you mean time since the game was last updated?

Time since the game was last updated

Edit: I was wrong I was able to get this working set of 3 commands.
First generate your tokens here
The tokens are between “token=“ and “&data”
The 8 digit is your public token and the 16 digit is your private token.

First Command: This is a timer so name doesn’t matter.

$(urlfetch $(eval Game="$(twitch CHANNEL_NAME "{{game}}")".replace(/\s/g,":");Time="$(time EST "MMMM Do YYYY hh:mm:ss a z")".replace(/\s/g,":");Data="$(urlfetch json".split(",");DC=Data[Data.length-1].split(" ");DC[1]!=Game?","+Time+"%20"+Game:"Nope"))

Set the interval to 5 minutes and the Chat lines to 2.
Set the alias to _game
Replace CHANNEL_NAME with your channel name and not $(channel) as nightbot only allows for three layers of nesting.

Second command: _game

$(eval a=" ";a)

Set no alias
Note: this just makes it so the timer doesn’t spam your chat.

Third Command: Call it whatever you want

$(channel) started playing $(eval Game="$(urlfetch json".split(",");GS=Game[Game.length-1].split(" ");GC=GS[1].replace(/:/g," ");GC) $(countup $(eval Time="$(urlfetch json".split(",");TS=Time[Time.length-1].split(" ");TC=TS[0].replace(/:/g," ");TC)) ago.

Set no alias

Final Notes: This updates the timer every 5 minutes if the game has changed so it will not be 100% accurate but for your purposes I hope this is sufficient. It also can’t detect if you stoped streaming then the next day you started streaming the same game. So in the case that happens the timer will be off.(if this is a problem let me know I think I may be able to fix it)

1 Like

Thank you so much!!!