Skip to content

In calc, properly convert large integers to pretty displays #325

Description

@RheingoldRiver

image

Exception in command 'calculator'
Traceback (most recent call last):
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/discord/ext/commands/core.py", line 187, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/bot/.local/share/Red-DiscordBot/data/tsubaki_prod/cogs/CogManager/cogs/calculator/calculator.py", line 132, in calculator
    em.add_field(name='Result (Fancy)', value=humanize_number(float(calc_result)), inline=False)
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/redbot/core/utils/chat_formatting.py", line 589, in humanize_number
    return format_decimal(val, locale=get_babel_regional_format(override_locale))
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/babel/numbers.py", line 421, in format_decimal
    return pattern.apply(
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/babel/numbers.py", line 1019, in apply
    number = self._quantize_value(value, locale, frac_prec, group_separator)
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/babel/numbers.py", line 1088, in _quantize_value
    rounded = value.quantize(quantum)
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1232, in invoke
    await ctx.command.invoke(ctx)
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/discord/ext/commands/core.py", line 931, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/bot/tsubaki/prod/lib/python3.8/site-packages/discord/ext/commands/core.py", line 196, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidOperation: [<class 'decimal.InvalidOperation'>]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions