From 70b9ec7dbdc346e7ddcac7624968424cf0e66ef6 Mon Sep 17 00:00:00 2001 From: evgriff Date: Fri, 10 Dec 2021 19:09:31 +0000 Subject: Added the user's score to Candy Command according to #947 --- bot/exts/holidays/halloween/candy_collection.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'bot') diff --git a/bot/exts/holidays/halloween/candy_collection.py b/bot/exts/holidays/halloween/candy_collection.py index bb9c93be..6edce1a0 100644 --- a/bot/exts/holidays/halloween/candy_collection.py +++ b/bot/exts/holidays/halloween/candy_collection.py @@ -173,6 +173,7 @@ class CandyCollection(commands.Cog): async def candy(self, ctx: commands.Context) -> None: """Get the candy leaderboard and save to JSON.""" records = await self.candy_records.items() + user = await self.bot.fetch_user(ctx.author.id) def generate_leaderboard() -> str: top_sorted = sorted( @@ -187,12 +188,23 @@ class CandyCollection(commands.Cog): for index, record in enumerate(top_five) ) if top_five else "No Candies" + def get_user_candy_score() -> str: + for user_id, score in records: + if user_id == user.id: + return f'<@{user.id}>: {score}' + return f'<@{user.id}>: 0' + e = discord.Embed(colour=discord.Colour.og_blurple()) e.add_field( name="Top Candy Records", value=generate_leaderboard(), inline=False ) + e.add_field( + name=f'{user.name}' + "'s Candy Score", + value=get_user_candy_score(), + inline=False + ) e.add_field( name="\u200b", value="Candies will randomly appear on messages sent. " -- cgit v1.2.3 From bcd47e1a0642dcc7c538d86d29c8311aed828bf5 Mon Sep 17 00:00:00 2001 From: evgriff Date: Fri, 10 Dec 2021 20:15:45 +0000 Subject: added key check --- bot/exts/utilities/issues.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/utilities/issues.py b/bot/exts/utilities/issues.py index b6d5a43e..b3f8340c 100644 --- a/bot/exts/utilities/issues.py +++ b/bot/exts/utilities/issues.py @@ -139,7 +139,7 @@ class Issues(commands.Cog): log.trace(f"PR provided, querying GH pulls API for additional information: {pulls_url}") async with self.bot.http_session.get(pulls_url) as p: pull_data = await p.json() - if pull_data["draft"]: + if "draft" in pull_data and pull_data["draft"]: emoji = Emojis.pull_request_draft elif pull_data["state"] == "open": emoji = Emojis.pull_request_open -- cgit v1.2.3 From 43f1a14765133229053c06bd36517f2f5081f20d Mon Sep 17 00:00:00 2001 From: evgriff Date: Wed, 15 Dec 2021 17:52:49 +0000 Subject: Adding suggestions, removing erroneous commit --- bot/exts/holidays/halloween/candy_collection.py | 9 ++++----- bot/exts/utilities/issues.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'bot') diff --git a/bot/exts/holidays/halloween/candy_collection.py b/bot/exts/holidays/halloween/candy_collection.py index 6edce1a0..9b16d543 100644 --- a/bot/exts/holidays/halloween/candy_collection.py +++ b/bot/exts/holidays/halloween/candy_collection.py @@ -173,7 +173,6 @@ class CandyCollection(commands.Cog): async def candy(self, ctx: commands.Context) -> None: """Get the candy leaderboard and save to JSON.""" records = await self.candy_records.items() - user = await self.bot.fetch_user(ctx.author.id) def generate_leaderboard() -> str: top_sorted = sorted( @@ -190,9 +189,9 @@ class CandyCollection(commands.Cog): def get_user_candy_score() -> str: for user_id, score in records: - if user_id == user.id: - return f'<@{user.id}>: {score}' - return f'<@{user.id}>: 0' + if user_id == ctx.author.id: + return f'<@{ctx.author.id}>: {score}' + return f'<@{ctx.author.id}>: 0' e = discord.Embed(colour=discord.Colour.og_blurple()) e.add_field( @@ -201,7 +200,7 @@ class CandyCollection(commands.Cog): inline=False ) e.add_field( - name=f'{user.name}' + "'s Candy Score", + name="Your Candy Score", value=get_user_candy_score(), inline=False ) diff --git a/bot/exts/utilities/issues.py b/bot/exts/utilities/issues.py index b3f8340c..b6d5a43e 100644 --- a/bot/exts/utilities/issues.py +++ b/bot/exts/utilities/issues.py @@ -139,7 +139,7 @@ class Issues(commands.Cog): log.trace(f"PR provided, querying GH pulls API for additional information: {pulls_url}") async with self.bot.http_session.get(pulls_url) as p: pull_data = await p.json() - if "draft" in pull_data and pull_data["draft"]: + if pull_data["draft"]: emoji = Emojis.pull_request_draft elif pull_data["state"] == "open": emoji = Emojis.pull_request_open -- cgit v1.2.3 From 85242f87d8c946b645d0ca50ed266a78dd51393d Mon Sep 17 00:00:00 2001 From: evgriff Date: Thu, 16 Dec 2021 20:06:44 +0000 Subject: user.mention --- bot/exts/holidays/halloween/candy_collection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/holidays/halloween/candy_collection.py b/bot/exts/holidays/halloween/candy_collection.py index 9b16d543..61dc8f97 100644 --- a/bot/exts/holidays/halloween/candy_collection.py +++ b/bot/exts/holidays/halloween/candy_collection.py @@ -190,8 +190,8 @@ class CandyCollection(commands.Cog): def get_user_candy_score() -> str: for user_id, score in records: if user_id == ctx.author.id: - return f'<@{ctx.author.id}>: {score}' - return f'<@{ctx.author.id}>: 0' + return f'{ctx.author.mention}: {score}' + return f'{ctx.author.mention}: 0' e = discord.Embed(colour=discord.Colour.og_blurple()) e.add_field( -- cgit v1.2.3 From e48fda5a7ae3509dd0ef7e591fedbf3dab125ba1 Mon Sep 17 00:00:00 2001 From: evgriff Date: Thu, 16 Dec 2021 20:09:12 +0000 Subject: Double quotes --- bot/exts/holidays/halloween/candy_collection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/holidays/halloween/candy_collection.py b/bot/exts/holidays/halloween/candy_collection.py index 61dc8f97..729bbc97 100644 --- a/bot/exts/holidays/halloween/candy_collection.py +++ b/bot/exts/holidays/halloween/candy_collection.py @@ -190,8 +190,8 @@ class CandyCollection(commands.Cog): def get_user_candy_score() -> str: for user_id, score in records: if user_id == ctx.author.id: - return f'{ctx.author.mention}: {score}' - return f'{ctx.author.mention}: 0' + return f"{ctx.author.mention}: {score}" + return f"{ctx.author.mention}: 0" e = discord.Embed(colour=discord.Colour.og_blurple()) e.add_field( -- cgit v1.2.3