diff --git a/bot/modules/economy/cointop_cmd.py b/bot/modules/economy/cointop_cmd.py index de53d91f..668ba80f 100644 --- a/bot/modules/economy/cointop_cmd.py +++ b/bot/modules/economy/cointop_cmd.py @@ -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: diff --git a/bot/modules/study/top_cmd.py b/bot/modules/study/top_cmd.py index bea0cca7..63bdf1b2 100644 --- a/bot/modules/study/top_cmd.py +++ b/bot/modules/study/top_cmd.py @@ -42,12 +42,20 @@ async def cmd_top(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', 'tracked_time'), - _extra="AND tracked_time > 0 ORDER BY tracked_time 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', '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 if not user_data: