Want to manually change a command’s count? Reset the count? Maybe you want to count by 5s or count to 10 & then reset. This is the right place.
Reset a command’s counter
!reset
!$(1) -c=0
owner/moderator
!editcom
I like to explain each command here. !editcom is shorthand for !command, & you’d have to type !edit before the command which is not ideal. Owner or moderator makes it so you don’t have to invoke stringquery, & it’s not like you’d want your viewers changing your !deaths counter to 69420.
“!reset fall” will change the !fall command’s counter to be 0. Nothing else is changed.
Change a counter to a specific non-0 value
!redo
!$(1) -c=$(2)
owner/moderator
!editcom
Same as above but usage is “!redo fall 7” in lieu of a command that decrements the counter by 1. Sadly, this seems to be the only way to do it.
!countby5
$(eval var max = 5; var C = $(count); C - max * Math.trunc((C - 1) / max))
everyone, owner/moderator
no alias
Latetsicario suggested this a while back & I finally figured out a way to do it. The solution is not to actually reset the counter, but to display a reset counter. If you play around with it, what it’s doing is counting up to 5 (you can change 5 to whatever number you’d like) & then when it gets to 6, it subtracts 5 from it. When it gets to 11, it subtracts 10. & so on. So the internal counter goes up forever, but Nightbot comments the count modulus 5, but adjusted so it doesn’t say “0”.
Choose a random number between X & Y
!random
Random number: $(eval var min = Number(decodeURIComponent('$(querystring $(1))')); var max = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(min) || isNaN(max)) { result = "Type '!random x y', where x & y are integers."; } else { Math.floor(Math.random() * (max - min + 1) + min) } )
everyone
no alias
Chooses an integer between 1 & 10, including both 1 & 10. This also works if you choose 1 & 100, 1 & 2, -56 & 1234, whatever you’d like!
Coin toss
!cointoss
🪙 $(eval var sides = ['Heads!','Tails!']; sides[Math.floor(Math.random() * 2)])
everyone
no alias
This is a simple adjustment of the !8ball command to display a coin toss instead. Uses a coin emoji!
Die roll
!die
🎲 $(eval var die = ['1','2','3','4','5','6']; die[Math.floor(Math.random() * 6)])
everyone
no alias
Same as above but for the roll of a die.
Dice roll
!dice
🎲🎲 $(eval var d1 = ['1','2','3','4','5','6']; var d2 = ['1','2','3','4','5','6']; d1 = d1[Math.floor(Math.random() * 6)]; d2 = d2[Math.floor(Math.random() * 6)]; var dice = Number(d1) + Number(d2); dice = "You rolled a " + dice + "!")
everyone
no alias
2 dice with possible rolls of 2–12 & the same probabilities you’d expect from real dice.
Math stuff
Preface: I won’t really explain the next ones too much, but the command tells you the syntax. Unfortunately, fractions don’t work, but positive, negative, & decimals work just fine! The long complicated commands are to ensure security, as using $(1) in JavaScript is a no-no. I also wanted to tell the user how to use the command without flooding chat every time someone uses it correctly.
All of these commands are available to everyone & have no alias. Just need to copy/paste twice each.
Addition/subtraction (with negative numbers)
!add
Sum: $(eval var x = Number(decodeURIComponent('$(querystring $(1))')); var y = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(x) || isNaN(y)) { result = "Type '!add x y', where x & y are integers or decimals."; } else { x + y } )
Multiplication
!mult
Product: $(eval var x = Number(decodeURIComponent('$(querystring $(1))')); var y = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(x) || isNaN(y)) { result = "Type '!mult x y', where x & y are integers or decimals."; } else { x * y } )
Division
!div
Quotient: $(eval var x = Number(decodeURIComponent('$(querystring $(1))')); var y = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(x) || isNaN(y)) { result = "Type '!div x y', where x & y are integers or decimals."; } else { x / y } )
Exponentiation
!exp
Power: $(eval var x = Number(decodeURIComponent('$(querystring $(1))')); var y = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(x) || isNaN(y)) { result = "Type '!exp x y', where x & y are integers or decimals."; } else { Math.pow(x, y) } )
Hypotenuse for 2 sides
!hypot
2D Hypotenuse: $(eval var x = Number(decodeURIComponent('$(querystring $(1))')); var y = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(x) || isNaN(y)) { result = "Type '!hypot x y', where x & y are integers or decimals."; } else { Math.hypot(x, y) } )
Hypotenuse for 3 sides
!hypot3
3D Hypotenuse: $(eval var x = Number(decodeURIComponent('$(querystring $(1))')); var y = Number(decodeURIComponent('$(querystring $(2))')); var z = Number(decodeURIComponent('$(querystring $(2))')); var result; if (isNaN(x) || isNaN(y) || isNaN(z)) { result = "Type '!hypot3 x y z', where x, y, & z are integers or decimals."; } else { Math.hypot(x, y, z) } )
More mathy stuff such as trigonometric functions & logarithms can be found at the JavaScript docs
I make use of the Number() function to ensure the inputs are the right type for JavaScript to do its thing; non-formated numbers like fractions won’t work & will result in null & NaN. At the top of the link you’ll also find constants like e, pi, log(10), & sqrt(2). Fun stuff!
I was unfortunately not able to figure out how to use a single command as a calculator, allowing “4 + 6” & “7 * 12” as inputs. Thus, I had to create separate commands for arithmetic. Subtraction I ignored as you can just use “!add 5 -2” to the same effect as “!sub 5 2”.
In the coming days, I want to create commands that take userlevel into account for the response. I also want to scroll through the forums for unanswered questions from years past to see if I can work my magic, but that may be overambitious. If you have any more complex commands you think would be helpful for the community, I’d like to make this a resource of sorts.