The command uses this link: https://api.mozambiquehe.re/maprotation?version=2&auth=APIKEY
Is it possible to hide the API key from other people using the command like if they were to check commands for my channel? If it will show in the command list under my Nightbot for my twitch channel, then disregard everything else here as the API key should be private.
I want to make a command that sends the “map” and “remainingTimer” under “current”, I want it to look like: "The current map is: “map” with “remainingTimer” left.
Then another command that sends the “map”, “readableDate_start” and “remainingMins” under “next”, which’ll say: "The next map is: “map” in “readableDate_start” for “remainingMins” minutes.
If possible, calculate how many hours before it’ll happen with the “readableDate_start”.
So no one will see the API key you are using in your request. Only people with access to add/edit commands will see the actual URL. If you do not want that, you would need to add some kind of proxy that would forward the request with the API key added on some server-side script.
For the commands, something like this should work:
Get current map
$(eval const api = $(urlfetch json https://api.mozambiquehe.re/maprotation?version=2&auth=APIKEY); "The current map is: " + api.battle_royale.current.map + " with " + api.battle_royale.current.remainingTimer + " left.")
Get next map
$(eval const api = $(urlfetch json https://api.mozambiquehe.re/maprotation?version=2&auth=APIKEY); "The next map is: " + api.battle_royale.next.map + " in " + api.battle_royale.next.readableDate_start + " for " + api.battle_royale.next.DurationInMinutes + " minutes.")
For a “fancy time” in the latter, you would need to know the timezone in which the dates are represented (most likely UTC, as most APIs do) and you could use the Countup command to make it look more fancy in there.
Would it be possible to convert “remainingTimer” to an easier way to read it? For example, “00:23:20” (hh:mm:ss) to 23 minutes and 20 seconds? Not sure how to use countup for this.
Making the assumption that the timestamp in remainingTimer will always be in hours:minutes:seconds format, you can split it on the colon and grab the elements separately.