Humanize number fix (#6283)

Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
aikaterna
2024-01-03 16:13:26 -08:00
committed by GitHub
parent 47a267b38b
commit 531b4fe357
6 changed files with 26 additions and 5 deletions

View File

@@ -758,9 +758,17 @@ class AudioSetCommands(MixinMeta, metaclass=CompositeMetaClass):
"""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."),
)
if price == 0:
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."),
)
elif price == 0:
jukebox = False
await self.send_embed_msg(
ctx, title=_("Setting Changed"), description=_("Jukebox mode disabled.")

View File

@@ -54,6 +54,9 @@ class Cleanup(commands.Cog):
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)

View File

@@ -40,7 +40,7 @@ class RPSParser:
self.choice = None
MAX_ROLL: Final[int] = 2**64 - 1
MAX_ROLL: Final[int] = 2**63 - 1
@cog_i18n(_)

View File

@@ -8,6 +8,9 @@ __all__ = ("finite_float",)
_ = Translator("Trivia", __file__)
MAX_VALUE = 2**63 - 1
def finite_float(arg: str) -> float:
try:
ret = float(arg)

View File

@@ -8,6 +8,7 @@ from redbot.core import bank, errors
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 @@ class TriviaSession:
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: