Trivia command
This commit is contained in:
1
funcs/roll/__init__.py
Normal file
1
funcs/roll/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .dice import roll_dice
|
@ -18,6 +18,23 @@ DICE_PATTERN = re.compile(
|
||||
IGNORECASE)
|
||||
|
||||
|
||||
def roll_dice(author : str, rollStr : str = "1d20"):
|
||||
if rollStr == '0/0': # easter eggs
|
||||
return("What do you expect me to do, destroy the universe?")
|
||||
|
||||
adv = 0
|
||||
if re.search('(^|\s+)(adv|dis)(\s+|$)', rollStr) is not None:
|
||||
adv = 1 if re.search('(^|\s+)adv(\s+|$)', rollStr) is not None else -1
|
||||
rollStr = re.sub('(adv|dis)(\s+|$)', '', rollStr)
|
||||
res = roll(rollStr, adv=adv)
|
||||
out = res.result
|
||||
outStr = author + ' :game_die:\n' + out
|
||||
if len(outStr) > 1999:
|
||||
outputs = author + ' :game_die:\n[Output truncated due to length]\n**Result:** ' + str(res.plain)
|
||||
else:
|
||||
outputs = outStr
|
||||
return(outputs)
|
||||
|
||||
def list_get(index, default, l):
|
||||
try:
|
||||
a = l[index]
|
||||
|
Reference in New Issue
Block a user