fix (Top): Handle empty exclude list.

This commit is contained in:
2021-09-19 13:42:40 +03:00
parent f23ba807da
commit 1a8a50538d
2 changed files with 28 additions and 12 deletions

View File

@@ -42,9 +42,17 @@ async def cmd_topcoin(ctx):
Lion.sync()
# Fetch the leaderboard
exclude = [m.id for m in ctx.guild_settings.unranked_roles.members]
if exclude:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
userid=data.NOT(exclude),
select_columns=('userid', 'coins'),
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "")
)
else:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
userid=data.NOT([m.id for m in ctx.guild_settings.unranked_roles.members]),
select_columns=('userid', 'coins'),
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "")
)

View File

@@ -42,9 +42,17 @@ async def cmd_top(ctx):
Lion.sync()
# Fetch the leaderboard
exclude = [m.id for m in ctx.guild_settings.unranked_roles.members]
if exclude:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
userid=data.NOT(exclude),
select_columns=('userid', 'tracked_time'),
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "")
)
else:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
userid=data.NOT([m.id for m in ctx.guild_settings.unranked_roles.members]),
select_columns=('userid', 'tracked_time'),
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "")
)