1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-03 00:03:13 +00:00
Lumi/modules/shop.py

59 lines
1.7 KiB
Python
Raw Normal View History

2023-07-02 11:30:47 +00:00
import json
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
2024-02-28 13:01:20 +00:00
from services.Currency import Currency
from services.ShopItem import ShopItem
2024-02-28 13:07:16 +00:00
from lib import checks
2023-07-02 11:30:47 +00:00
load_dotenv('.env')
special_balance_name = os.getenv("SPECIAL_BALANCE_NAME")
cash_balance_name = os.getenv("CASH_BALANCE_NAME")
with open("config/economy.json") as file:
json_data = json.load(file)
class ShopCog(commands.Cog):
2024-02-28 13:01:20 +00:00
def __init__(self, client):
2024-02-28 13:11:22 +00:00
self.client = client
2023-07-02 11:30:47 +00:00
@commands.slash_command(
name="shop",
description="Display the shop.",
guild_only=True
)
2024-02-28 13:01:20 +00:00
@commands.check(checks.beta_command)
2023-07-02 11:30:47 +00:00
async def shop(self, ctx):
shop = ShopItem.get_shop_all()
embed = discord.Embed(
color=discord.Color.embed_background(),
title="Racu Shop",
description="The shop is updated regularly!"
)
embed.set_footer(text="do /buy <item>")
for item in shop:
2024-02-28 13:11:22 +00:00
emoji = self.client.get_emoji(item.item.emote_id)
2023-07-02 11:30:47 +00:00
if item.price != 0 and item.price_special != 0:
2023-07-18 19:08:15 +00:00
price = f"${Currency.format(item.price)} *or* {Currency.format(item.price_special)} {special_balance_name}"
2023-07-02 11:30:47 +00:00
elif item.price == 0:
price = f"{item.price_special} {special_balance_name}"
else:
2023-07-18 19:08:15 +00:00
price = f"${Currency.format(item.price)}"
2023-07-02 11:30:47 +00:00
embed.add_field(name=f"{emoji} {item.item.display_name} - {price}",
value=f"\n*{item.description}*",
inline=False)
await ctx.respond(embed=embed)
2024-02-28 13:01:20 +00:00
def setup(client):
client.add_cog(ShopCog(client))