diff options
| author | 2021-12-03 02:45:04 +0400 | |
|---|---|---|
| committer | 2021-12-03 02:45:04 +0400 | |
| commit | 617bcfb4a962252fd72e68d8c8a5578c728f7e14 (patch) | |
| tree | a947ca67db48e8c2f83397d4c6a77484b5486a94 | |
| parent | Merge pull request #900 from python-discord/update-role-constants (diff) | |
| parent | Merge branch 'main' into aoc-lb-multiword (diff) | |
Merge pull request #963 from python-discord/aoc-lb-multiword
Make self_placement_name keyword-only in .aoc lb
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/events/advent_of_code/_cog.py | 23 | 
1 files changed, 13 insertions, 10 deletions
| diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py index 65a16fdd..3ad24b3b 100644 --- a/bot/exts/events/advent_of_code/_cog.py +++ b/bot/exts/events/advent_of_code/_cog.py @@ -220,20 +220,23 @@ class AdventOfCode(commands.Cog):          brief="Get a snapshot of the PyDis private AoC leaderboard",      )      @whitelist_override(channels=AOC_WHITELIST_RESTRICTED) -    async def aoc_leaderboard( -            self, -            ctx: commands.Context, -            self_placement_name: Optional[str] = None, -    ) -> None: +    async def aoc_leaderboard(self, ctx: commands.Context, *, aoc_name: Optional[str] = None) -> None:          """          Get the current top scorers of the Python Discord Leaderboard. -        Additionally you can specify a `self_placement_name` -        that will append the specified profile's personal stats to the top of the leaderboard +        Additionally you can specify an `aoc_name` that will append the +        specified profile's personal stats to the top of the leaderboard          """ +        # Strip quotes from the AoC username if needed (e.g. "My Name" -> My Name) +        # This is to keep compatibility with those already used to wrapping the AoC name in quotes +        # Note: only strips one layer of quotes to allow names with quotes at the start and end +        #      e.g. ""My Name"" -> "My Name" +        if aoc_name and aoc_name.startswith('"') and aoc_name.endswith('"'): +            aoc_name = aoc_name[1:-1] +          async with ctx.typing():              try: -                leaderboard = await _helpers.fetch_leaderboard(self_placement_name=self_placement_name) +                leaderboard = await _helpers.fetch_leaderboard(self_placement_name=aoc_name)              except _helpers.FetchingLeaderboardFailedError:                  await ctx.send(":x: Unable to fetch leaderboard!")                  return @@ -241,10 +244,10 @@ 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 self_placement_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 self_placement_name else leaderboard['top_leaderboard']}" \ +                f"{leaderboard['placement_leaderboard'] if aoc_name else leaderboard['top_leaderboard']}" \                  "\n```"          info_embed = _helpers.get_summary_embed(leaderboard) | 
