@@ -226,13 +226,17 @@ async def join_leaderboard(self, interaction: discord.Interaction) -> None:
226226 await interaction .response .send_message ("\n " .join (info_str ), ephemeral = True )
227227
228228 @in_month (Month .NOVEMBER , Month .DECEMBER , Month .JANUARY , Month .FEBRUARY )
229- @adventofcode_group .command (
229+ @adventofcode_group .app_command . command (
230230 name = "link" ,
231- aliases = ("connect" ,),
232- brief = "Tie your Discord account with your Advent of Code name."
231+ description = "Tie your Discord account with your Advent of Code name." ,
233232 )
234233 @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
235- async def aoc_link_account (self , ctx : commands .Context , * , aoc_name : str | None = None ) -> None :
234+ async def aoc_link_account (
235+ self ,
236+ interaction : discord .Interaction ,
237+ * ,
238+ aoc_name : str | None = None ,
239+ ) -> None :
236240 """
237241 Link your Discord Account to your Advent of Code name.
238242
@@ -243,61 +247,78 @@ async def aoc_link_account(self, ctx: commands.Context, *, aoc_name: str | None
243247
244248 if aoc_name :
245249 # Let's check the current values in the cache to make sure it isn't already tied to a different account
246- if aoc_name == await self .account_links .get (ctx .author .id ):
247- await ctx .reply (f"{ aoc_name } is already tied to your account." , ephemeral = True )
250+ if aoc_name == await self .account_links .get (interaction .user .id ):
251+ await interaction .response .send_message (
252+ f"{ aoc_name } is already tied to your account." ,
253+ ephemeral = True ,
254+ )
248255 return
256+
249257 if aoc_name in cache_aoc_names :
250258 log .info (
251- f"{ ctx . author } ({ ctx . author .id } ) tried to connect their account to { aoc_name } ,"
259+ f"{ interaction . user } ({ interaction . user .id } ) tried to connect their account to { aoc_name } ,"
252260 " but it's already connected to another user."
253261 )
254- await ctx . reply (
262+ await interaction . response . send_message (
255263 f"{ aoc_name } is already tied to another account."
256264 " Please contact an admin if you believe this is an error." ,
257265 ephemeral = True ,
258266 )
259267 return
260268
261269 # Update an existing link
262- if old_aoc_name := await self .account_links .get (ctx .author .id ):
263- log .info (f"Changing link for { ctx .author } ({ ctx .author .id } ) from { old_aoc_name } to { aoc_name } ." )
264- await self .account_links .set (ctx .author .id , aoc_name )
265- await ctx .reply (f"Your linked account has been changed to { aoc_name } ." )
270+ if old_aoc_name := await self .account_links .get (interaction .user .id ):
271+ log .info (
272+ f"Changing link for { interaction .user .id } ({ interaction .user .id } ) "
273+ f"from { old_aoc_name } to { aoc_name } ."
274+ )
275+ await self .account_links .set (interaction .user .id , aoc_name )
276+ await interaction .response .send_message (f"Your linked account has been changed to { aoc_name } ." )
266277 else :
267278 # Create a new link
268- log .info (f"Linking { ctx . author } ({ ctx . author .id } ) to account { aoc_name } ." )
269- await self .account_links .set (ctx . author .id , aoc_name )
270- await ctx . reply (f"You have linked your Discord ID to { aoc_name } ." )
279+ log .info (f"Linking { interaction . user } ({ interaction . user .id } ) to account { aoc_name } ." )
280+ await self .account_links .set (interaction . user .id , aoc_name )
281+ await interaction . response . send_message (f"You have linked your Discord ID to { aoc_name } ." )
271282 else :
272283 # User has not supplied a name, let's check if they're in the cache or not
273- if cache_name := await self .account_links .get (ctx .author .id ):
274- await ctx .reply (f"You have already linked an Advent of Code account: { cache_name } ." )
284+ if cache_name := await self .account_links .get (interaction .user .id ):
285+ await interaction .response .send_message (
286+ f"You have already linked an Advent of Code account: { cache_name } ."
287+ )
275288 else :
276- await ctx . reply (
289+ await interaction . response . send_message (
277290 "You have not linked an Advent of Code account."
278291 " Please re-run the command with one specified."
279292 )
280293
281294 @in_month (Month .NOVEMBER , Month .DECEMBER , Month .JANUARY , Month .FEBRUARY )
282- @adventofcode_group .command (
295+ @adventofcode_group .app_command . command (
283296 name = "unlink" ,
284- aliases = ("disconnect" ,),
285- brief = "Untie your Discord account from your Advent of Code name."
297+ description = "Untie your Discord account from your Advent of Code name." ,
286298 )
287299 @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
288- async def aoc_unlink_account (self , ctx : commands . Context ) -> None :
300+ async def aoc_unlink_account (self , interaction : discord . Interaction ) -> None :
289301 """
290302 Unlink your Discord ID with your Advent of Code leaderboard name.
291303
292304 Deletes the entry that was Stored in the Redis cache.
293305 """
294- if aoc_cache_name := await self .account_links .get (ctx .author .id ):
295- log .info (f"Unlinking { ctx .author } ({ ctx .author .id } ) from Advent of Code account { aoc_cache_name } " )
296- await self .account_links .delete (ctx .author .id )
297- await ctx .reply (f"We have removed the link between your Discord ID and { aoc_cache_name } ." , ephemeral = True )
306+ if aoc_cache_name := await self .account_links .get (interaction .user .id ):
307+ log .info (
308+ f"Unlinking { interaction .user } ({ interaction .user .id } ) "
309+ f"from Advent of Code account { aoc_cache_name } "
310+ )
311+ await self .account_links .delete (interaction .user .id )
312+ await interaction .response .send_message (
313+ f"We have removed the link between your Discord ID and { aoc_cache_name } ." ,
314+ ephemeral = True ,
315+ )
298316 else :
299- log .info (f"Attempted to unlink { ctx .author } ({ ctx .author .id } ), but no link was found." )
300- await ctx .reply ("You don't have an Advent of Code account linked." , ephemeral = True )
317+ log .info (f"Attempted to unlink { interaction .user } ({ interaction .user .id } ), but no link was found." )
318+ await interaction .response .send_message (
319+ "You don't have an Advent of Code account linked." ,
320+ ephemeral = True ,
321+ )
301322
302323 @in_month (Month .DECEMBER , Month .JANUARY , Month .FEBRUARY )
303324 @adventofcode_group .command (
0 commit comments