aboutsummaryrefslogtreecommitdiff
path: root/modules/dice.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-26 14:48:05 +0100
committerGravatar jesopo2019-09-26 14:48:05 +0100
commit2c8b3749cf81bec155fe91c5016ce5e81241d272 (patch)
tree1385911a9f005f5bcc0e6679d2db99ac5246717c /modules/dice.py
parentmake dice count optional (default 1) (diff)
signature
default !roll to 1d6
Diffstat (limited to 'modules/dice.py')
-rw-r--r--modules/dice.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/dice.py b/modules/dice.py
index 16f3a550..cf4f53a2 100644
--- a/modules/dice.py
+++ b/modules/dice.py
@@ -11,12 +11,18 @@ MAX_DICE = 6
MAX_SIDES = 100
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.roll", min_args=1)
+ @utils.hook("received.command.roll")
@utils.hook("received.command.dice", alias_of="roll")
@utils.kwarg("help", "Roll dice DND-style")
@utils.kwarg("usage", "[1-%s]d[1-%d]" % (MAX_DICE, MAX_SIDES))
def roll_dice(self, event):
- match = RE_DICE.match(event["args_split"][0])
+ args = None
+ if event["args_split"]:
+ args = event["args_split"][0]
+ else:
+ args = "1d6"
+
+ match = RE_DICE.match(args)
if match:
roll = match.group(0)
dice_count = int(match.group(1) or "1")