Browse Source

made the expression optional to get the help output and made sure that the help output has something about adding numbers to the sum.

tags/v1.6.0
Roxie Gibson 6 years ago
parent
commit
cd595c725a
2 changed files with 14 additions and 3 deletions
  1. +14
    -2
      Roxbot/cogs/fun.py
  2. +0
    -1
      main.py

+ 14
- 2
Roxbot/cogs/fun.py View File

@@ -14,7 +14,7 @@ class Fun:
self.bot = bot_client

@bot.command()
async def roll(self, ctx, expression):
async def roll(self, ctx, expression = ""):
"""
Rolls a die using dice expression format.
Usage:
@@ -23,6 +23,18 @@ class Fun:
Example:
.roll 2d20h1 + 7 # Rolls two D20s takes the highest 1, then adds 7
.roll #will give brief overview of dice expression format

Dice expression format:
An expression can consist of many sub expressions added together and then a multiplier at the end to indicate how many times the expression should be rolled.
Sub expressions can be of many types:
<number> #add this number to the total
d<sides> #roll a dice with that many sides and add it to the total
<n>d<sides> #roll n dice. each of those dice have <sides> number of sides, sum all the dice and add to the total
add r<number> #reroll any rolls below <number>
add h<number> #only sum the <number> highest rolls rather than all of them
add l<number> #only sum the <number> lowest rolls rather than all of them
+<number> # Add this number to the sum.
x<number> #only use at the end. roll the rest of the expression <number> times(max 10)")
"""
response = ''
rollVerbose = True
@@ -44,7 +56,7 @@ class Fun:
response += "*Warning:* was unable to resolve how many times this command was meant to run. defaulted to once.\n"
m=re.findall('(-?)((?:(\d*)d(\d*))|\d+)(r\d*)?([h,l]{1}\d*)?',parts[0])
if m == []:
return await ctx.send("Dice expression format:\n\nAn expression can consist of many sub expressions added together and then a multiplier at the end to indicate how many times the expression should be rolled.\n\nSub expressions can be of many types:\n<number> #add this number to the total\nd<sides> #roll a dice with that many sides and add it to the total\n<n>d<sides> #roll n dice. each of those dice have <sides> number of sides, sum all the dice and add to the total\n\tadd r<number> #reroll any rolls below <number>\n\tadd h<number> #only sum the <number> highest rolls rather than all of them\n\tadd l<number> #only sum the <number> lowest rolls rather than all of them\nx<number> #only use at the end. roll the rest of the expression <number> times(max 10)")
return await ctx.send("Expression missing. If you are unsure of what the format should be, please use `{}help roll`".format(ctx.prefix))
dice = []
for item in m:
temp = [0]*5

+ 0
- 1
main.py View File

@@ -35,7 +35,6 @@ def blacklisted(user):
async def on_ready():
# Load Roxbots inbuilt cogs and settings
bot.load_extension("Roxbot.settings.settings")
bot.load_extension("Roxbot.settings.backup")
bot.load_extension("Roxbot.err_handle")
bot.load_extension("Roxbot.logging")
bot.settings = gs.get_all(bot.guilds)

Loading…
Cancel
Save