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