diff --git a/redbot/cogs/audio/core/commands/audioset.py b/redbot/cogs/audio/core/commands/audioset.py index 2ad0e0bbf61..57194fd649e 100644 --- a/redbot/cogs/audio/core/commands/audioset.py +++ b/redbot/cogs/audio/core/commands/audioset.py @@ -758,9 +758,17 @@ async def command_audioset_jukebox(self, ctx: commands.Context, price: int): """Set a price for queueing tracks for non-mods, 0 to disable.""" if price < 0: return await self.send_embed_msg( - ctx, title=_("Invalid Price"), description=_("Price can't be less than zero.") + ctx, + title=_("Invalid Price"), + description=_("Price can't be less than zero."), + ) + elif price > 2**63 - 1: + return await self.send_embed_msg( + ctx, + title=_("Invalid Price"), + description=_("Price can't be greater than 2^63 - 1."), ) - if price == 0: + elif price == 0: jukebox = False await self.send_embed_msg( ctx, title=_("Setting Changed"), description=_("Jukebox mode disabled.") diff --git a/redbot/cogs/cleanup/cleanup.py b/redbot/cogs/cleanup/cleanup.py index bd3095f2487..27bd4398fcd 100644 --- a/redbot/cogs/cleanup/cleanup.py +++ b/redbot/cogs/cleanup/cleanup.py @@ -54,6 +54,9 @@ async def check_100_plus(ctx: commands.Context, number: int) -> bool: if ctx.assume_yes: return True + if number > 2**63 - 1: + return await ctx.send(_("Try a smaller number instead.")) + prompt = await ctx.send( _("Are you sure you want to delete {number} messages?").format( number=humanize_number(number) diff --git a/redbot/cogs/general/general.py b/redbot/cogs/general/general.py index 1ffb1b97162..8e251fee594 100644 --- a/redbot/cogs/general/general.py +++ b/redbot/cogs/general/general.py @@ -40,7 +40,7 @@ def __init__(self, argument): self.choice = None -MAX_ROLL: Final[int] = 2**64 - 1 +MAX_ROLL: Final[int] = 2**63 - 1 @cog_i18n(_) diff --git a/redbot/cogs/trivia/converters.py b/redbot/cogs/trivia/converters.py index 211ed5d4bbe..a5b7a41eedc 100644 --- a/redbot/cogs/trivia/converters.py +++ b/redbot/cogs/trivia/converters.py @@ -8,6 +8,9 @@ _ = Translator("Trivia", __file__) +MAX_VALUE = 2**63 - 1 + + def finite_float(arg: str) -> float: try: ret = float(arg) diff --git a/redbot/cogs/trivia/session.py b/redbot/cogs/trivia/session.py index 824d75e5f00..abe31e0aa00 100644 --- a/redbot/cogs/trivia/session.py +++ b/redbot/cogs/trivia/session.py @@ -8,6 +8,7 @@ from redbot.core.i18n import Translator from redbot.core.utils.chat_formatting import box, bold, humanize_list, humanize_number from redbot.core.utils.common_filters import normalize_smartquotes +from .converters import MAX_VALUE from .log import LOG __all__ = ["TriviaSession"] @@ -320,6 +321,7 @@ async def pay_winners(self, multiplier: float): if not winners or num_humans < 3: return payout = int(top_score * multiplier / len(winners)) + payout = MAX_VALUE if payout > MAX_VALUE else payout if payout <= 0: return for winner in winners: diff --git a/redbot/core/utils/chat_formatting.py b/redbot/core/utils/chat_formatting.py index 8cf37e8a267..afcfc2d126d 100644 --- a/redbot/core/utils/chat_formatting.py +++ b/redbot/core/utils/chat_formatting.py @@ -576,7 +576,7 @@ def humanize_timedelta( def humanize_number(val: Union[int, float], override_locale=None) -> str: """ - Convert an int or float to a str with digit separators based on bot locale + Convert an int or float to a str with digit separators based on bot locale. Parameters ---------- @@ -585,10 +585,15 @@ def humanize_number(val: Union[int, float], override_locale=None) -> str: override_locale: Optional[str] A value to override bot's regional format. + Raises + ------ + decimals.InvalidOperation + If val is greater than 10 x 10^21 for some locales, 10 x 10^24 in others. + Returns ------- str - locale aware formatted number. + Locale-aware formatted number. """ return format_decimal(val, locale=get_babel_regional_format(override_locale))