fix (Top): Handle empty exclude list.
This commit is contained in:
@@ -42,12 +42,20 @@ async def cmd_topcoin(ctx):
|
|||||||
Lion.sync()
|
Lion.sync()
|
||||||
|
|
||||||
# Fetch the leaderboard
|
# Fetch the leaderboard
|
||||||
user_data = tables.lions.select_where(
|
exclude = [m.id for m in ctx.guild_settings.unranked_roles.members]
|
||||||
guildid=ctx.guild.id,
|
if exclude:
|
||||||
userid=data.NOT([m.id for m in ctx.guild_settings.unranked_roles.members]),
|
user_data = tables.lions.select_where(
|
||||||
select_columns=('userid', 'coins'),
|
guildid=ctx.guild.id,
|
||||||
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "")
|
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
|
# Quit early if the leaderboard is empty
|
||||||
if not user_data:
|
if not user_data:
|
||||||
|
|||||||
@@ -42,12 +42,20 @@ async def cmd_top(ctx):
|
|||||||
Lion.sync()
|
Lion.sync()
|
||||||
|
|
||||||
# Fetch the leaderboard
|
# Fetch the leaderboard
|
||||||
user_data = tables.lions.select_where(
|
exclude = [m.id for m in ctx.guild_settings.unranked_roles.members]
|
||||||
guildid=ctx.guild.id,
|
if exclude:
|
||||||
userid=data.NOT([m.id for m in ctx.guild_settings.unranked_roles.members]),
|
user_data = tables.lions.select_where(
|
||||||
select_columns=('userid', 'tracked_time'),
|
guildid=ctx.guild.id,
|
||||||
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "")
|
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,
|
||||||
|
select_columns=('userid', 'tracked_time'),
|
||||||
|
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "")
|
||||||
|
)
|
||||||
|
|
||||||
# Quit early if the leaderboard is empty
|
# Quit early if the leaderboard is empty
|
||||||
if not user_data:
|
if not user_data:
|
||||||
|
|||||||
Reference in New Issue
Block a user