I am brand new to nightbot and I want to set up a !duel command where the user challenges nightbot to a duel but rather than a random 50/50 I would like to make it in nightbot's favor so that winning the duel is even more significant. I want it to be a 1 in 50 chance of beating nightbot. If anyone could help I would greatly appreciate it.
Duel command with percentage for nightbot winning
21 replies
Yes you could do that you’d need three or more commands one with an alias and the use of an API to keep track of it but it is technically possible. There is a slightly less complicated version of this which would require manual entry /t/win-loss-death-kill-counters-in-one-command/1534599429502537921#m153459943… and a more complex version that would update it automatically you’ll need a separate command to see the wins and losses to. If you need me to I’ll edit the above code to make it automatically update if you want but either way let me know.
For these you’ll need to generate private and public tokens how it explains in the post I linked.
!Main_command_name
$(eval Math.floor(Math.random()*50)==0?`w`:`l`)
Alias it to _count
_count
$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(1))`;`$(1)`==`w`?`WIN_MESSAGE`:`LOSS_MESSAGE`)
!NAME_OF_COUNT_COMMAND
$(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`;w=q.replace(/l/g,``);l=q.replace(/w/g,``);w==null?w=0:w=w.length;l==null?l=0:l=l.length;`Wins: ${w} | Losses: ${l}`)
Please note I wrote this all at 3 am so there may very well be mistakes but hopefully it works first go :)
Please read the first few paragraphs of this post /t/win-loss-death-kill-counters-in-one-command/1534599429502537921#m153459943…
And I tested out the commands and they work fine.
(Please ignore the names of the commands)

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