diff options
| author | 2018-12-10 16:46:06 -0500 | |
|---|---|---|
| committer | 2018-12-10 16:46:06 -0500 | |
| commit | 0de62cc2ba50b2cef6e998cc797aaba1685d50b1 (patch) | |
| tree | 20501694696f571ef0f0931d39288dadff00623f /bot | |
| parent | Update static files for new code functionality (diff) | |
Refactor aoc join to DM user with join code
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/seasons/christmas/adventofcode.py | 16 | 
1 files changed, 13 insertions, 3 deletions
| diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 458eb19f..b61e77c0 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -19,6 +19,7 @@ log = logging.getLogger(__name__)  AOC_REQUEST_HEADER = {"user-agent": "PythonDiscord AoC Event Bot"}  AOC_SESSION_COOKIE = {"session": Tokens.aoc_session_cookie} +AOC_JOIN_CODE = AocConfig.leaderboard_join_code  # Constant so staff can update without redeploying  EST = timezone("EST")  COUNTDOWN_STEP = 60 * 5 @@ -196,14 +197,23 @@ class AdventOfCode:      @adventofcode_group.command(name="join", aliases=("j",), brief="Learn how to join PyDis' private AoC leaderboard")      async def join_leaderboard(self, ctx: commands.Context):          """ -        Retrieve the link to join the PyDis AoC private leaderboard +        DM the user the information for joining the PyDis AoC private leaderboard          """ +        author = ctx.message.author +        log.info(f"{author.name} ({author.id}) has requested the PyDis AoC leaderboard code") +          info_str = (              "Head over to https://adventofcode.com/leaderboard/private " -            f"with code `{AocConfig.leaderboard_join_code}` to join the PyDis private leaderboard!" +            f"with code `{AOC_JOIN_CODE}` to join the PyDis private leaderboard!"          ) -        await ctx.send(info_str) +        try: +            await author.send(info_str) +        except discord.errors.Forbidden: +            log.debug(f"{author.name} ({author.id}) has disabled DMs from server members") +            await ctx.send( +                f':x: {author.mention}, please (temporarily) enable DMs to receive the join code' +            )      @adventofcode_group.command(          name="leaderboard", | 
