From 57c7b1aaa35fab079b8e0844e434b0281fdbe41a Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 26 May 2025 04:44:26 -0400 Subject: [PATCH] Update leaderboard point calculation logic in Leaderboard cog to handle global bank balance retrieval and improve LevelUp XP fetching. Enhance error handling for user data access and ensure accurate total points computation. --- leaderboard/leaderboard.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/leaderboard/leaderboard.py b/leaderboard/leaderboard.py index c211ff3..b430103 100644 --- a/leaderboard/leaderboard.py +++ b/leaderboard/leaderboard.py @@ -113,9 +113,12 @@ class Leaderboard(commands.Cog): """Get a user's total points combining bank balance and levelup XP.""" total_points = 0 - # Get bank balance + # Get bank balance (credits) try: - balance = await bank.get_balance(user) + if await bank.is_global(): + balance = await bank.get_balance(user) + else: + balance = await bank.get_balance(user, _forced=True) total_points += balance except Exception as e: log.error(f"Error getting bank balance for {user}: {e}") @@ -124,9 +127,9 @@ class Leaderboard(commands.Cog): levelup = self.bot.get_cog("LevelUp") if levelup: try: - conf = levelup.db.get_conf(user.guild) - profile = conf.get_profile(user) - total_points += int(profile.xp) + profile = await levelup.get_user_profile(user) + if profile: + total_points += int(profile.total_xp) except Exception as e: log.error(f"Error getting LevelUp XP for {user}: {e}")