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.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
This commit is contained in:
parent
b688f7a605
commit
57c7b1aaa3
1 changed files with 8 additions and 5 deletions
|
@ -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}")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue