1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 20:23:12 +00:00

Finish currency formatting

This commit is contained in:
wlinator 2023-07-18 15:08:15 -04:00
parent 66ce9ff821
commit 19780ed10f
2 changed files with 8 additions and 13 deletions

View file

@ -1,11 +1,11 @@
import json
import locale
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from data.ShopItem import ShopItem
from sb_tools import universal
@ -39,16 +39,13 @@ class ShopCog(commands.Cog):
for item in shop:
emoji = self.bot.get_emoji(item.item.emote_id)
locale.setlocale(locale.LC_ALL, '')
if item.price != 0 and item.price_special != 0:
item.price = locale.format_string("%d", item.price, grouping=True)
price = f"${item.price} *or* {item.price_special} {special_balance_name}"
price = f"${Currency.format(item.price)} *or* {Currency.format(item.price_special)} {special_balance_name}"
elif item.price == 0:
price = f"{item.price_special} {special_balance_name}"
else:
item.price = locale.format_string("%d", item.price, grouping=True)
price = f"${item.price}"
price = f"${Currency.format(item.price)}"
embed.add_field(name=f"{emoji} {item.item.display_name} - {price}",
value=f"\n*{item.description}*",

View file

@ -1,5 +1,4 @@
import json
import locale
import os
import discord
@ -7,6 +6,7 @@ from discord.ext import commands
from dotenv import load_dotenv
from data.BlackJackStats import BlackJackStats
from data.Currency import Currency
from data.SlotsStats import SlotsStats
from main import strings, economy_config
from sb_tools import universal
@ -38,9 +38,8 @@ class StatsCog(commands.Cog):
stats = BlackJackStats.get_user_stats(ctx.author.id)
# amount formatting
locale.setlocale(locale.LC_ALL, '')
total_bet = locale.format_string("%d", stats["total_bet"], grouping=True)
total_payout = locale.format_string("%d", stats["total_payout"], grouping=True)
total_bet = Currency.format_human(stats["total_bet"])
total_payout = Currency.format_human(stats["total_payout"])
# output = f"{ctx.author.name}'s racu stats\n\n"
output = strings["stats_blackjack"].format(
@ -54,9 +53,8 @@ class StatsCog(commands.Cog):
stats = SlotsStats.get_user_stats(ctx.author.id)
# amount formatting
locale.setlocale(locale.LC_ALL, '')
total_bet = locale.format_string("%d", stats["total_bet"], grouping=True)
total_payout = locale.format_string("%d", stats["total_payout"], grouping=True)
total_bet = Currency.format_human(stats["total_bet"])
total_payout = Currency.format_human(stats["total_payout"])
output = strings["stats_slots"].format(stats["amount_of_games"], total_bet, total_payout)
output += "\n\n"