diff options
| author | 2021-12-03 18:46:39 -0500 | |
|---|---|---|
| committer | 2021-12-03 21:48:00 -0500 | |
| commit | 846c34fd8988eaede08186fa9fb342213dc85585 (patch) | |
| tree | 3612066aecbaf6cac4e322da6ad7288328a0ed5a /bot/exts | |
| parent | Add `.aoc link` command (diff) | |
Remove unneeded check and add comments
Removes the unneeded check for if the cache is empty.
Also adds a seconds comment about the format of the contents
of the Redis cache.
Diffstat (limited to 'bot/exts')
| -rw-r--r-- | bot/exts/events/advent_of_code/_cog.py | 17 | 
1 files changed, 2 insertions, 15 deletions
| diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py index 1b1cd9f8..8d87b5bc 100644 --- a/bot/exts/events/advent_of_code/_cog.py +++ b/bot/exts/events/advent_of_code/_cog.py @@ -30,6 +30,7 @@ AOC_WHITELIST = AOC_WHITELIST_RESTRICTED + (Channels.advent_of_code,)  class AdventOfCode(commands.Cog):      """Advent of Code festivities! Ho Ho Ho!""" +    # Redis Cache for linking Discord IDs to Advent of Code usernames      account_links = RedisCache()      def __init__(self, bot: Bot): @@ -186,23 +187,9 @@ class AdventOfCode(commands.Cog):          """          Link your Discord Account to your Advent of Code name. -        Stored in a Redis Cache, Discord ID: Advent of Code Name +        Stored in a Redis Cache with the format of `Discord ID: Advent of Code Name`          """          cache_items = await self.account_links.items() - -        # A short circuit in case the cache is empty -        if len(cache_items) == 0 and aoc_name: -            log.info(f"{ctx.author} ({ctx.author.id}) is now linked to {aoc_name}.") -            await self.account_links.set(ctx.author.id, aoc_name) -            await ctx.reply(f"You have linked your Discord ID to {aoc_name}.") -            return -        elif len(cache_items) == 0: -            await ctx.reply( -                "You have not linked an Advent of Code account." -                "Please re-run the command with one specified." -            ) -            return -          cache_aoc_name = [value for _, value in cache_items]          if aoc_name: | 
