Skip to content

Commit

Permalink
Merge pull request #25 from zeroquinc:trophies-console
Browse files Browse the repository at this point in the history
feature: add console name to embed
  • Loading branch information
zeroquinc authored May 10, 2024
2 parents 02f259a + e031327 commit 96cde8a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/trophies.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ def get_earned_trophies(client, title_ids):
try:
earned_trophies = client.trophies(np_communication_id=trophy_title.np_communication_id, platform=platform, trophy_group_id='all', include_metadata=True)
# Add each trophy and its title to the list
trophies.extend((trophy, trophy_title) for trophy in earned_trophies)
trophies.extend((trophy, {'trophy_title': trophy_title, 'platform': platform}) for trophy in earned_trophies)
except Exception as e:
logger.error(f"Failed to get trophies for platform {platform}: {e}")
return trophies

def create_trophy_embed(trophy, trophy_title, client, current, total_trophies):
def create_trophy_embed(trophy, trophy_title_info, client, current, total_trophies):
trophy_title = trophy_title_info['trophy_title']
platform = trophy_title_info['platform']
most_common_color = get_discord_color(trophy.trophy_icon_url)
completion = current
percentage = (completion / total_trophies) * 100
embed = discord.Embed(description=f"**{trophy_title.title_name}** \n\n {trophy.trophy_detail} \n\n Unlocked by {trophy.trophy_earn_rate}% of players", color=most_common_color)
embed = discord.Embed(description=f"**{trophy_title.title_name} ({platform})** \n\n {trophy.trophy_detail} \n\n Unlocked by {trophy.trophy_earn_rate}% of players", color=most_common_color)
embed.add_field(name="Trophy", value=f"[{trophy.trophy_name}]({trophy.trophy_icon_url})", inline=True)
embed.add_field(name="Completion", value=f"{completion}/{total_trophies} ({percentage:.2f}%)", inline=True)
embed.set_image(url=DISCORD_IMAGE)
Expand Down

0 comments on commit 96cde8a

Please sign in to comment.