diff options
author | 2021-12-10 19:09:31 +0000 | |
---|---|---|
committer | 2021-12-10 19:09:31 +0000 | |
commit | 70b9ec7dbdc346e7ddcac7624968424cf0e66ef6 (patch) | |
tree | 3b6193c4b33004dc74b1bfa3c1d4d947143c2e8c | |
parent | Merge pull request #951 from python-discord/file_logging (diff) |
Added the user's score to Candy Command according to #947
-rw-r--r-- | bot/exts/holidays/halloween/candy_collection.py | 12 |
1 files changed, 12 insertions, 0 deletions
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,6 +188,12 @@ 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", @@ -194,6 +201,11 @@ class CandyCollection(commands.Cog): 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. " "\nHit the candy when it appears as fast as possible to get the candy! " |