just a pick a number simple enough but I need it to return if/then and just can’t get it.
Example: !pickanumber 10 (return YOU ARE CORRECT!) if the output matches the user input and (Sorry Try Again) if the number is incorrect. I just can’t get the code right. Any help would be greatly appreciated.
!pickanumber 8
Nightbot:The number is 8 YOU ARE CORRECT
!pickanumber 5
Nightbot The Number is 7 Sorry Try Again
Thanks -JTS
/e I have been trying to work with this code but still not quite what I am looking for I need it to check against the user input if == then A if not then respond B
!NAME $(eval var a = (Math.floor(Math.random() * 100)); if (a>99) { var b = ’ 100 Test '; b; } else { var b = ’ Less than 99 '; b; } )
!addcom !shoot $(eval const roll = Math.floor(Math.random() * 100) + 1; roll === Number(`$(querystring)`) ? `YOU HIT THE BLUE DOT! 8 points` : `U MISSED. You scored 0`)
I appreciate the reply but its still missing the mark. Maybe I am failing to explain it properly. The idea is that the (user) adds a number after the !command. I am looking for it to then roll a random number and compare to user input and then return “a” or “b” based on a match or not.
!shoot 9
Nightbot the number is 7 Sorry Try again
!shoot 7
Nightbot The Number is 7 YOU ARE CORRCT.
I am just lost at this point. the simple random number works I am just trying to add the second part of it.
!addcom !shoot $(eval const roll = Math.floor(Math.random() * 100) + 1; roll === Number(`$(querystring)`) ? `The Number is ${roll} YOU ARE CORRCT.` : `the Number is ${roll} Sorry Try again`)