diff --git a/leaderboard/leaderboard.py b/leaderboard/leaderboard.py index a216c12..9560de7 100644 --- a/leaderboard/leaderboard.py +++ b/leaderboard/leaderboard.py @@ -358,17 +358,17 @@ class Leaderboard(commands.Cog): if not chunks: return await ctx.send("No users have 10,000 or more credits!") - # Send warning message first - await ctx.send("āš ļø **Note:** The global leaderboard may be slightly inaccurate due to synchronization delays.") - embeds = [] for page_num, entries in enumerate(chunks, 1): embed = discord.Embed( - title="šŸ† Global Credits Leaderboard", - description="*Only showing users with 10,000+ credits*", + title="Global Credits Leaderboard", color=await ctx.embed_color() ) + # Add server icon if available + if ctx.guild.icon: + embed.set_thumbnail(url=ctx.guild.icon.url) + description = [] start_pos = (page_num - 1) * items_per_page @@ -377,12 +377,26 @@ class Leaderboard(commands.Cog): user_id = entry.get("userId", "0") credits = entry.get("points", 0) + # Calculate percentage position + percentage = (i / len(leaderboard_data)) * 100 + + # Medal emojis for top 3 + medal = "šŸ„‡" if i == 1 else "🄈" if i == 2 else "šŸ„‰" if i == 3 else "•" + description.append( - f"`{i}.` <@{user_id}> • **{humanize_number(credits)}** credits" + f"`{i}.` {medal} <@{user_id}>\n" + f"ā”— šŸ’° **{humanize_number(credits)}** credits • Top **{percentage:.1f}%**" ) - embed.description = embed.description + "\n\n" + "\n".join(description) - embed.set_footer(text=f"Page {page_num}/{len(chunks)} • Total Users: {len(leaderboard_data)}") + embed.description = "\n".join(description) + + # Modern footer with stats + total_credits = sum(entry["points"] for entry in leaderboard_data) + embed.set_footer( + text=f"Page {page_num}/{len(chunks)} • {len(leaderboard_data):,} Users • {humanize_number(total_credits)} Total Credits", + icon_url=self.bot.user.display_avatar.url + ) + embed.timestamp = datetime.now(timezone.utc) embeds.append(embed) view = LeaderboardView(self, ctx, embeds) @@ -442,30 +456,49 @@ class Leaderboard(commands.Cog): # Debug logging log.info(f"Credits check for {member}: {credits} credits") - # Get user's rank + # Get user's rank and total users for percentage calculation leaderboard_data = await self.get_all_balances() + total_users = len(leaderboard_data) rank = next( (i for i, entry in enumerate(leaderboard_data, 1) if entry.get("userId") == str(member.id)), None ) + # Calculate percentage (top x%) + percentage = (rank / total_users * 100) if rank and total_users > 0 else None + embed = discord.Embed( - title="šŸ† Global Credits", + title="", # Modern design: no title needed color=await ctx.embed_color() ) if credits >= 10000: - embed.description = ( - f"**User:** {member.mention}\n" - f"**Credits:** {humanize_number(credits)}\n" - f"**Rank:** #{humanize_number(rank) if rank else 'Unranked'}\n" - f"**ID:** {member.id}" - ) - else: - embed.description = f"{member.mention} has less than 10,000 credits ({humanize_number(credits)} total)" + # Modern stat display with emojis and clean formatting + stats = [ + f"šŸ’° **{humanize_number(credits)}** credits", + f"šŸ“Š Rank **#{humanize_number(rank)}**" if rank else "šŸ“Š Unranked", + f"šŸŽÆ Top **{percentage:.1f}%**" if percentage else "", + f"šŸ†” `{member.id}`" + ] - embed.set_thumbnail(url=member.display_avatar.url) + embed.description = "\n".join(s for s in stats if s) # Only include non-empty stats + else: + embed.description = f"šŸ’° **{humanize_number(credits)}** credits\nā— *Minimum 10,000 credits needed for ranking*" + + # Modern avatar display + embed.set_author( + name=member.display_name, + icon_url=member.display_avatar.url + ) + + # Add a subtle footer with timestamp + embed.set_footer( + text="Global Leaderboard Stats", + icon_url=ctx.guild.icon.url if ctx.guild.icon else None + ) + embed.timestamp = datetime.now(timezone.utc) + await ctx.send(embed=embed) @globalboard.command(name="resync")