dicebot
This bot rolls dice and evaluates simple math expressions in Discord messages
You interact with it by sending messages in a channel the bot can see
Requires you to update .env with a private DISCORD_TOKEN if you want to host your own
- Short form:
/r <expression>.r <expression>!r <expression>
- Long form:
/roll <expression>.roll <expression>!roll <expression>
Supported pieces of an expression:
- Dice
NdM→ roll N, M-sided dice (e.g.3d6)dM→ shorthand for1dM(e.g.d20)
- Integers
- Whole numbers (e.g.
5,-2)
- Whole numbers (e.g.
- Operators (integer arithmetic)
+addition-subtraction*multiplication/division (truncating, DICE DON'T ROLL DECIMALS!)^exponent (non-negative, limited size)
- Parentheses
(and)to control order of operations
Operator precedence: ^ > * / > + -.
You can make dice “explode” – when a die meets a condition, it rolls again and adds to that die’s total.
-
Add
!after a dice term: -
NdM!→ explode on max (e.g.d6!explodes on 6) -
NdM!<X– explode if a roll is less than X (e.g.d6!<3explodes on 1–2) -
NdM!=X– explode if a roll is equal to X (e.g.d10!=1explodes on 1)
Each die may roll multiple times; all rolls for that die are summed, and only the final total per die is shown.
- There is a hard cap on explosion chains of 512 rerolls to avoid infinite loops.