diff options
| author | 2021-12-03 21:29:01 -0500 | |
|---|---|---|
| committer | 2021-12-03 21:51:56 -0500 | |
| commit | b134010e1682a40d2aa9e3ce893c274388896680 (patch) | |
| tree | 8911e518dafb0309039533c9aaed5a9b2ba7cbaa | |
| parent | Merge branch 'main' into aoc-link (diff) | |
Adjust `.aoc lb` to use linked account in cache
If the user has not supplied a name to use for the leaderboard, then
code will check if they have an account linked. If they do, it will use
the linked account in the leaderboard to show placement.
| -rw-r--r-- | bot/exts/events/advent_of_code/_cog.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py index 16176c69..49b604ab 100644 --- a/bot/exts/events/advent_of_code/_cog.py +++ b/bot/exts/events/advent_of_code/_cog.py @@ -311,6 +311,10 @@ class AdventOfCode(commands.Cog): if aoc_name and aoc_name.startswith('"') and aoc_name.endswith('"'): aoc_name = aoc_name[1:-1] + # Check if an advent of code account is linked in the Redis Cache if aoc_name is not given + if (aoc_cache_name := await self.account_links.get(ctx.author.id)) and aoc_name is None: + aoc_name = aoc_cache_name + async with ctx.typing(): try: leaderboard = await _helpers.fetch_leaderboard(self_placement_name=aoc_name) @@ -321,7 +325,7 @@ class AdventOfCode(commands.Cog): number_of_participants = leaderboard["number_of_participants"] top_count = min(AocConfig.leaderboard_displayed_members, number_of_participants) - self_placement_header = "(and your personal stats compared to the top 10)" if aoc_name else "" + self_placement_header = " (and your personal stats compared to the top 10)" if aoc_name else "" header = f"Here's our current top {top_count}{self_placement_header}! {Emojis.christmas_tree * 3}" table = "```\n" \ f"{leaderboard['placement_leaderboard'] if aoc_name else leaderboard['top_leaderboard']}" \ |