Duel command with percentage for nightbot winning

Actually for a 50/50 you’ll wanna make that a 2 and not 50 :stuck_out_tongue:

$(eval Math.floor(Math.random()*2)==0?`USER_WINS_MESSAGE`:`USER_LOSES_MESSAGE`)
1 Like

Thanks this is working great!

1 Like

I actually wanted the 1 in 50 chance, but this is useful to know how to change the math. Thanks!

Opps sorry I cant read :stuck_out_tongue:

One more thing I thought of. Is there a way to make it count the number of wins and losses separately? Or does counting only work for the command use?

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 Win-Loss Counter with customapi - #3 by Emily 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.

1 Like

I would like it to update automatically.
if you don’t mind editing it that would be great!

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 :slight_smile:

1 Like

It seems like its almost there. i ran the main command a few times but the count just says 25 for wins and losses. and I really do appreciate the help at this hour but no rush if you want to get back to me later about it

Can you give your public token?

im not sure how to do that

I just need your 8 digit public token so I can check something

where would i find that? im completely new to all this

Ok when you added the commands did you replace “PUBLIC” and “PRIVATE” “_TOKEN”?

1 Like

i pretty much just copy pasted everything but changed the ‘WIN_MESSAGE’" and “LOSS_MESSAGE” was i supposed to replace the ‘w’ and ‘l’ in the main command with the same win and loss message?

Please read the first few paragraphs of this post Win-Loss Counter with customapi - #3 by Emily

And I tested out the commands and they work fine.


(Please ignore the names of the commands)

1 Like

okay i will check that out. and just to be clear is there anything else that I am supposed to change other than the win and loss messages?

Yes specifically PUBLIC_TOKEN and PRIVATE_TOKEN There is absolutely no way they will work unless you use those.

1 Like

oh okay. that must be what im missing. sorry, I dont know much about this. ill check out the link and see if i can get it going. Thank you so much for this :blush:

2 Likes

It’s working! Once again I really appreciate it and thank you for dealing with my Naivety :grin:

1 Like