[General] Max amount to roll (#3395)

* [General] Rolls max amount

Adds max amount to roll.

* Removed redundant code.

* QA changes

* Add typehinting.
This commit is contained in:
Stonedestroyer 2020-01-20 22:49:46 +01:00 committed by Michael H
parent 7f390df879
commit b085c1501f
2 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1 @@
[General] Adds a maximum amount to roll command.

View File

@ -2,6 +2,7 @@ import datetime
import time
from enum import Enum
from random import randint, choice
from typing import Final
import aiohttp
import discord
from redbot.core import commands
@ -31,6 +32,9 @@ class RPSParser:
self.choice = None
MAX_ROLL: Final[int] = 2 ** 64 - 1
@cog_i18n(_)
class General(commands.Cog):
"""General commands."""
@ -87,15 +91,21 @@ class General(commands.Cog):
`<number>` defaults to 100.
"""
author = ctx.author
if number > 1:
if 1 < number <= MAX_ROLL:
n = randint(1, number)
await ctx.send(
"{author.mention} :game_die: {n} :game_die:".format(
author=author, n=humanize_number(n)
)
)
else:
elif number <= 1:
await ctx.send(_("{author.mention} Maybe higher than 1? ;P").format(author=author))
else:
await ctx.send(
_("{author.mention} Max allowed number is {maxamount}.").format(
author=author, maxamount=humanize_number(MAX_ROLL)
)
)
@commands.command()
async def flip(self, ctx, user: discord.Member = None):