Skip to content

Commit

Permalink
Tags, Shop, and Profile Fixes (#531)
Browse files Browse the repository at this point in the history
* various small fixes

* flip this back to debug
  • Loading branch information
zmattingly committed Jun 2, 2024
1 parent 709df10 commit bce1469
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions charts/agimus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: agimus
description: A helm chart for a discord bot that also runs a mysql db
type: application
version: v2.9.0
appVersion: v2.9.0
version: v2.9.1
appVersion: v2.9.1
15 changes: 9 additions & 6 deletions cogs/badge_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,18 @@ async def callback(self, interaction:discord.Interaction):


class TagBadgeView(discord.ui.View):
def __init__(self, cog, user_discord_id, badge_info, associated_tags):
def __init__(self, user_discord_id, badge_info, user_badge_tags, associated_tags):
super().__init__()
self.cog = cog
self.tag_ids = []
self.add_item(TagSelector(user_discord_id, associated_tags))
self.add_item(TagSelector(user_badge_tags, associated_tags))
self.add_item(TagButton(user_discord_id, badge_info))

async def generateTagBadgeView(user_discord_id, badge_info):
user_badge_tags = await db_get_user_badge_tags(user_discord_id)
associated_tags = await db_get_associated_badge_tags(user_discord_id, badge_info['badge_filename'])

return TagBadgeView(user_discord_id, badge_info, user_badge_tags, associated_tags)


class TagCarouselView(discord.ui.View):
def __init__(self, user_discord_id, badge_info, user_badge_tags, associated_tags):
Expand Down Expand Up @@ -462,9 +467,7 @@ async def tag(self, ctx:discord.ApplicationContext, badge:str):
return

badge_info = await db_get_badge_info_by_name(badge)
associated_tags = await db_get_associated_badge_tags(ctx.author.id, badge_info['badge_filename'])

view = TagBadgeView(self, ctx.author.id, badge_info, associated_tags)
view = await generateTagBadgeView(ctx.author.id, badge_info)
embed = discord.Embed(
title=badge,
color=discord.Color.dark_purple()
Expand Down
8 changes: 4 additions & 4 deletions cogs/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ async def display(self, ctx:discord.ApplicationContext, public:str):
draw.text( (283, 80), f"USS HOOD PERSONNEL FILE #{str(member.id)[-4:]}", fill=random.choice(lcars_colors), font=level_font, align="right")
draw.text( (79, 95), f"AGIMUS MAIN TERMINAL", fill="#dd4444", font=agimus_font, align="center",)
draw.text( (470, 182), f"{user_name[0:32]}", fill="white", font=name_font, align="center", anchor="ms")
if user['tagline']:
draw.text( (470, 233), f"\"{user['tagline']}\"", fill="white", font=entry_font, align="center", anchor="ms")
if user['profile_tagline']:
draw.text( (470, 233), f"\"{user['profile_tagline']}\"", fill="white", font=entry_font, align="center", anchor="ms")
draw.text( (578, 381), f"LEVEL: {user['level']:03d}", fill="white", font=level_font, align="right" )
title_color = random.choice(lcars_colors[1:3])
draw.text( (250, 385), f"CURRENT RANK:", fill=title_color, font=title_font, align="left")
Expand Down Expand Up @@ -342,8 +342,8 @@ async def display(self, ctx:discord.ApplicationContext, public:str):


# put polaroid on
if user["photo"] and user["photo"] != "none":
profile_photo = user['photo'].replace(" ", "_")
if user["profile_photo"] and user["profile_photo"] != "none":
profile_photo = user['profile_photo'].replace(" ", "_")
photo_image = Image.open("./images/profiles/template_pieces/lcars/photo-frame.png").convert("RGBA")
photo_content = Image.open(f"./images/profiles/polaroids/{profile_photo}.jpg").convert("RGBA")

Expand Down
7 changes: 4 additions & 3 deletions cogs/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ async def get_role_pages(self, user_id: int = None):
role_pages.append(card_page)
return role_pages

def get_style_pages(self, user_id: int = None):
async def get_style_pages(self, user_id: int = None):
"""
Returns an array of ShopPages for styles
"""
style_pages = []
user_styles = [s['item_name'] for s in db_get_user_profile_styles_from_inventory(user_id)]
user_styles = [s['item_name'] for s in await db_get_user_profile_styles_from_inventory(user_id)]

for idx, style in enumerate(self.shop_data["styles"]):
if style['name'] in user_styles:
Expand Down Expand Up @@ -434,8 +434,9 @@ async def styles(self, ctx: discord.ApplicationContext):
view = discord.ui.View()
view.add_item(BuyButton(self))

style_pages = await self.get_style_pages(ctx.user.id)
paginator = pages.Paginator(
pages=self.get_style_pages(ctx.user.id),
pages=style_pages,
use_default_buttons=False,
custom_buttons=self.get_custom_buttons(),
trigger_on_display=True,
Expand Down
11 changes: 10 additions & 1 deletion common.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,16 @@ def uniq_channels(config):
async def get_user(discord_id:int):
async with AgimusDB(dictionary=True) as query:
# get user basic info
sql = "SELECT users.*, profile_photos.photo as photo, profile_taglines.tagline as tagline FROM users LEFT JOIN profile_taglines ON profile_taglines.user_discord_id = users.discord_id LEFT JOIN profile_photos ON profile_photos.user_discord_id = users.discord_id WHERE discord_id = %s"
sql = """
SELECT
users.*,`x
profile_photos.photo AS profile_photo,
profile_taglines.tagline AS profile_tagline
FROM users
LEFT JOIN profile_taglines ON profile_taglines.user_discord_id = users.discord_id
LEFT JOIN profile_photos ON profile_photos.user_discord_id = users.discord_id
WHERE users.discord_id = %s
"""
vals = (discord_id,)
await query.execute(sql, vals)
user_data = await query.fetchone()
Expand Down

0 comments on commit bce1469

Please sign in to comment.