Creating a leaderboard for a custom command

Asked Jun 14, 2024·1 reply·Last activity 2 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'm new to using Nightbot/coding in general, and I've spent a couple of hours getting a little text-based game working in my chat.
My commands are:

$(eval z=3600;d=Date.parse(Date());a=$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_KEY).match(/~$(user)~\d+~/g);PRIVATE_KEY+(!a||d-parseInt(a[a.length-1].split(~)[2])>=z*1000?&data=~$(user)~${d}~:``))

$(eval a=$(urlfetch https://twitch.center/customapi/addquote?token=$(query));decodeURIComponent($(querystring)).includes(PRIVATE_KEY)?(a.includes(Successfully added entry)?$(user) draws back their bow, aims, and fires! Great shot $(eval a=$(urlfetch json https://pastebin.com/raw/xxxxxxxx);a[Math.floor(Math.random()*a.length)]):You've run out of arrows!): )

With my public and private keys, as well as pastebin URL correct, naturally.
The objective of the game is to fire an arrow once per hour, the person then receives a score or miss from the pastebin list. Ranging from "Great shot you miss the target completely!" to "Great shot you hit the BULLSEYE - 10POINTS!

My question is, is there a way to pull data from the shots taken and accumulate the scores into a leaderboard? Or if not accumulative scores, simply a 'Highest score of the day'?

1 reply

This far exceeds the general use case of the 3rd party quote system. You'd need to create your own API else where with the logic your looking for in order to reduce the complexity on the Nightbot command.