Code:
on $*:text:/^!(\d+)d(\d+)(\+(\d+))?$/g:#: {
  ; $regml(1) is the number before the d
  ; $regml(2) is the number after the d
  ; $regml(3) is the number after the +
  ; You dont need the +num so it will work without it or with it
    var %1 = $regml(1)
    var %2 = $regml(2)
    var %3 = $regml(3)
  if (%2 !isnum 2-1000) || (%1 !isnum 1-200) .notice $nick The number of sides on the die must be within 2-1000, the number of die that are rolled must be within 1-200.
  else {
    while (%1) {
      dec %1
      var %4 = $calc(%4 + $rand(1,%2))
    }
    msg $chan $nick $+ , You rolled $calc(%4 + %3) in total.
  }
}


i tested it and it works perfectly. grin