diff options
author | AnInternetTroll <lucafulger@gmail.com> | 2021-04-04 12:48:42 +0000 |
---|---|---|
committer | AnInternetTroll <lucafulger@gmail.com> | 2021-04-04 12:48:42 +0000 |
commit | 6ae27f8b7f395b1ff4acab43214619d54736a274 (patch) | |
tree | dd93f6d590045960bf21aeb4a3bce6bdcbb968d3 /cogs/utils.py | |
parent | 189ff921e5a1e14569fb49c44bf679b1b86f2869 (diff) | |
download | steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.tar steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.tar.gz steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.tar.bz2 steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.tar.lz steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.tar.xz steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.tar.zst steve-bot-6ae27f8b7f395b1ff4acab43214619d54736a274.zip |
Reformatting
Diffstat (limited to '')
-rwxr-xr-x | cogs/utils.py | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/cogs/utils.py b/cogs/utils.py index 1ad303d..ed43b7c 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -119,7 +119,8 @@ class Utils(commands.Cog): rigged_findseed = { 280428276810383370: 12, # Thomas's User ID 199070670221475842: -1, # Kai's User ID - 615658069132836865: -12, # What a fraud! They didn't use their real name. + # What a fraud! They didn't use their real name. + 615658069132836865: -12, } if ctx.author.id in rigged_findseed: @@ -517,29 +518,34 @@ class Utils(commands.Cog): f"{discord.utils.escape_mentions(ctx.message.author.display_name)} your timezone has been set to {timeZone}" ) - @commands.cooldown(2, 60, commands.BucketType.guild) - @commands.command() - async def fboard(self, ctx, requested: str = "streak"): - """Show fair leaderboard (day or streak).""" - # get fair object - with open("fair.json", "r") as f: - fair = json.load(f) - - #Detect people who didn't maintain their streak. + @commands.cooldown(2, 60, commands.BucketType.guild) + @commands.command() + async def fboard(self, ctx, requested: str = "streak"): + """Show fair leaderboard (day or streak).""" + # get fair object + with open("fair.json", "r") as f: + fair = json.load(f) + + # Detect people who didn't maintain their streak. for user in fair: - tz = fair[user]["timezone"] - currentdate = datetime.datetime.now(timezone(tz)).date() - if fair[user]["date"] != str(currentdate) and fair[user]["date"] != str(currentdate-timedelta(1)): + tz = fair[user]["timezone"] + currentdate = datetime.datetime.now(timezone(tz)).date() + if fair[user]["date"] != str(currentdate) and fair[user]["date"] != str( + currentdate - timedelta(1) + ): fair[user]["streak"] = 1 - fair[user]["date"] = str(currentdate) - await ctx.send(self.bot.get_user(int(user)).mention + ": You lost your streak! <:sad:716629485449117708>") + fair[user]["date"] = str(currentdate) + await ctx.send( + self.bot.get_user(int(user)).mention + + ": You lost your streak! <:sad:716629485449117708>" + ) with open("fair.json", "w") as f: json.dump(fair, f, indent=4) leaderboard = [] - - #String the requested info with its respective user and store it in our list + + # String the requested info with its respective user and store it in our list if requested.lower() == "day": for user in fair: leaderboard.append(str(fair[user]["day"]) + user) @@ -551,25 +557,28 @@ class Utils(commands.Cog): flag = "Streak" else: - await ctx.send("Request the leaderboard by \"day\" or \"streak\".") + await ctx.send('Request the leaderboard by "day" or "streak".') return - #Sort the "info + user" strings as ints. + # Sort the "info + user" strings as ints. leaderboard.sort(reverse=True, key=int) - text = "" - embed = discord.Embed(title="Fair Leaderboard", color=7853978, timestamp=ctx.message.created_at) - - #Get the top 10 entries and extract the info and user from each string + text = "" + embed = discord.Embed( + title="Fair Leaderboard", color=7853978, timestamp=ctx.message.created_at + ) + + # Get the top 10 entries and extract the info and user from each string for i in range(10): entry = leaderboard[i][:-18] userstr = leaderboard[i][-18:] text = text + f"{i+1}. {self.bot.get_user(int(userstr))}: {entry} \n" - embed.add_field(name=flag, value=discord.utils.escape_mentions(text), inline=False) - + embed.add_field( + name=flag, value=discord.utils.escape_mentions(text), inline=False + ) + await ctx.send(embed=embed) - @commands.cooldown(1, 60, commands.BucketType.member) @commands.command() |