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

64 lines
1.8 KiB
Python
Raw Normal View History

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.Inventory import Inventory
2024-02-28 13:07:16 +00:00
from lib import checks
load_dotenv('.env')
active_blackjack_games = {}
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 InventoryCog(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
@commands.slash_command(
name="inventory",
description="Display your inventory.",
guild_only=True
)
2024-02-28 13:01:20 +00:00
@commands.check(checks.channel)
async def inventory(self, ctx):
inventory = Inventory(ctx.author.id)
inventory_dict = inventory.get_inventory()
description = "You don't have any items!" if inventory_dict == {} else None
embed = discord.Embed(
color=discord.Color.embed_background(),
description=description
)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar.url)
for item, quantity in inventory_dict.items():
2023-07-03 10:32:20 +00:00
if item.type == "badge":
2023-06-29 20:05:05 +00:00
if not embed.description:
embed.description = "**Badges:** "
2024-02-28 13:11:22 +00:00
emote = self.client.get_emoji(item.emote_id)
2023-06-29 20:05:05 +00:00
embed.description += f"{emote} "
else:
2024-02-28 13:11:22 +00:00
emote = self.client.get_emoji(item.emote_id)
2023-06-29 20:05:05 +00:00
embed.add_field(name=f"{emote} {item.display_name.capitalize()}",
2023-06-29 20:19:50 +00:00
value=f"*— amount: `{quantity}`*",
2023-06-29 20:05:05 +00:00
inline=False)
embed.set_footer(text="for more info do /item")
await ctx.respond(embed=embed)
2024-02-28 13:01:20 +00:00
def setup(client):
client.add_cog(InventoryCog(client))