From 35bfa0c91c2df34e971a485e6734065e9cbb0f5c Mon Sep 17 00:00:00 2001 From: Seth Scherer Date: Sat, 16 Apr 2022 17:34:38 -0400 Subject: [PATCH] Adds a new GBP finding command (#32) `finduntil`, with a number as an argument will print every user up until that position on the leaderboard --- gbp/gbp.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gbp/gbp.py b/gbp/gbp.py index ea65fcc..b05b87e 100644 --- a/gbp/gbp.py +++ b/gbp/gbp.py @@ -100,3 +100,19 @@ async def findgbp(self, ctx, gbp_to_find): await ctx.send(file=utils.chat_formatting.text_to_file(msg, "gbp.txt")) else: await ctx.send(f"```{msg}```") + + @commands.command() + async def finduntil(self, ctx, up_to_pos): + msg = "" + gbp_dict = await self.config.gbp() + for i in range(1, len(gbp_dict) + 1): + if int(up_to_pos) < i: + break + msg += "#" + str(i) + ": " + gbp_dict[str(i)][0] + " (" + str(gbp_dict[str(i)][1]) + " GBP)\n" + if (msg == ""): + await ctx.send("An error has occured!") + return + if (len(msg) >= 2000): + await ctx.send(file=utils.chat_formatting.text_to_file(msg, "gbp.txt")) + else: + await ctx.send(f"```{msg}```")