Skip to content

Commit

Permalink
Fix ranking on logs with empty user
Browse files Browse the repository at this point in the history
  • Loading branch information
davafons committed Feb 13, 2024
1 parent 626bc42 commit 596e147
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 11 additions & 5 deletions immersion_bot/cogs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,6 @@ async def log(
print(f"2. Updated monthly stats: {all_users_ranking}")
print("-- END TRANSACTION")

ranking_message = await self.get_ranking_message(
all_users_ranking, user_index, user_ranking_stats, awarded_points
)
print(ranking_message)
embed = discord.Embed(
title=f"Log registrado para {interaction.user.display_name}",
colour=Colour.from_rgb(46, 204, 113),
Expand All @@ -565,7 +561,17 @@ async def log(
value=f"{round(user_ranking_stats.points, 2)} puntos",
inline=False,
)
embed.add_field(name="Ranking", value=ranking_message)

if user_ranking_stats:
ranking_message = (
await self.get_ranking_message(
all_users_ranking, user_index, user_ranking_stats, awarded_points
)
if user_ranking_stats
else ""
)
print(ranking_message)
embed.add_field(name="Ranking", value=ranking_message)

embed.set_footer(text=f"LOG ID - {log_id}")

Expand Down
3 changes: 3 additions & 0 deletions immersion_bot/launch_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ async def on_ready(self):
await bot_owner.create_dm()
self.bot_owner_dm_channel = bot_owner.dm_channel

# self.tree.copy_global_to(guild=discord.Object(id=GUILD_ID))
# await self.tree.sync(guild=discord.Object(id=GUILD_ID))

await self.change_presence(activity=discord.Game(presence_message))
print(f"Logged in as\n\tName: {self.user.name}\n\tID: {self.user.id}")
print(f"Running pycord version: {discord.__version__}")
Expand Down

0 comments on commit 596e147

Please sign in to comment.