aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar astieman <[email protected]>2019-02-14 21:32:10 -0700
committerGravatar astieman <[email protected]>2019-02-14 21:32:10 -0700
commit03c07170279efd43ab4ac4e593db978cd0bab3ef (patch)
treef480d9b7f2d1002055a44a53e76933c8024be21a
parentReadded fun.py file to evergreen and added roll command. (diff)
Code review changes implemented. Reverted so error handling is done by base bot.
Diffstat (limited to '')
-rw-r--r--bot/seasons/evergreen/fun.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/bot/seasons/evergreen/fun.py b/bot/seasons/evergreen/fun.py
index ebc10fca..afe70462 100644
--- a/bot/seasons/evergreen/fun.py
+++ b/bot/seasons/evergreen/fun.py
@@ -15,22 +15,14 @@ class Fun:
self.bot = bot
@commands.command()
- async def roll(self, ctx, str_input: str = None):
+ async def roll(self, ctx, num_rolls: int):
output = ""
-
- if not str_input:
- output = "To use .roll, format it as such: .roll (number)"
- else:
- try:
- num_rolls = int(str_input)
- if num_rolls > 6:
- num_rolls = 6
- elif num_rolls < 1:
- return
- for i in range(num_rolls):
- output += ":terning%d: " % random.randint(1, 6)
- except ValueError:
- return
+ if num_rolls > 6:
+ num_rolls = 6
+ elif num_rolls < 0:
+ output = ":no_entry: You must roll at least once."
+ for _ in range(num_rolls):
+ output += ":terning%d: " % random.randint(1, 6)
await ctx.send(output)