mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[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:
parent
7f390df879
commit
b085c1501f
1
changelog.d/general/3284.bugfix.rst
Normal file
1
changelog.d/general/3284.bugfix.rst
Normal file
@ -0,0 +1 @@
|
||||
[General] Adds a maximum amount to roll command.
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user