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,12 +42,20 @@ async def cmd_topcoin(ctx):
Lion.sync()
# Fetch the leaderboard
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 "")
)
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,
select_columns=('userid', 'coins'),
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "")
)
# Quit early if the leaderboard is empty
if not user_data: