aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts
diff options
context:
space:
mode:
authorGravatar Janine vN <[email protected]>2021-12-03 20:50:17 -0500
committerGravatar Janine vN <[email protected]>2021-12-03 21:48:10 -0500
commit1ac965f67fea8e5dd0e0f026aca27e3368f4e44e (patch)
tree6d935e08fe563c36915625d0b104d5a682a4e94d /bot/exts
parentRemove unneeded check and add comments (diff)
Add unlink AoC command
Adds the ability for the user to unlink their advent of code name. It will delete the entry in the cache if it exists.
Diffstat (limited to 'bot/exts')
-rw-r--r--bot/exts/events/advent_of_code/_cog.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py
index 8d87b5bc..7f904f6b 100644
--- a/bot/exts/events/advent_of_code/_cog.py
+++ b/bot/exts/events/advent_of_code/_cog.py
@@ -228,6 +228,27 @@ class AdventOfCode(commands.Cog):
" Please re-run the command with one specified."
)
+ @in_month(Month.NOVEMBER, Month.DECEMBER)
+ @adventofcode_group.command(
+ name="unlink",
+ aliases=("disconnect",),
+ brief="Tie your Discord account with your Advent of Code name."
+ )
+ @whitelist_override(channels=AOC_WHITELIST)
+ async def aoc_unlink_account(self, ctx: commands.Context) -> None:
+ """
+ Unlink your Discord ID with your Advent of Code leaderboard name.
+
+ Deletes the entry that was Stored in the Redis cache.
+ """
+ if aoc_cache_name := await self.account_links.get(ctx.author.id):
+ log.info(f"Unlinking {ctx.author} ({ctx.author.id}) from Advent of Code account {aoc_cache_name}")
+ await self.account_links.delete(ctx.author.id)
+ await ctx.reply(f"We have removed the link between your Discord ID and {aoc_cache_name}.")
+ else:
+ log.info(f"Attempted to unlink {ctx.author} ({ctx.author.id}), but not link was found.")
+ await ctx.reply("You don't have an Advent of Code account linked.")
+
@in_month(Month.DECEMBER)
@adventofcode_group.command(
name="dayandstar",