@@ -226,13 +226,17 @@ async def join_leaderboard(self, interaction: discord.Interaction) -> None:
226
226
await interaction .response .send_message ("\n " .join (info_str ), ephemeral = True )
227
227
228
228
@in_month (Month .NOVEMBER , Month .DECEMBER , Month .JANUARY , Month .FEBRUARY )
229
- @adventofcode_group .command (
229
+ @adventofcode_group .app_command . command (
230
230
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." ,
233
232
)
234
233
@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 :
236
240
"""
237
241
Link your Discord Account to your Advent of Code name.
238
242
@@ -243,61 +247,78 @@ async def aoc_link_account(self, ctx: commands.Context, *, aoc_name: str | None
243
247
244
248
if aoc_name :
245
249
# 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
+ )
248
255
return
256
+
249
257
if aoc_name in cache_aoc_names :
250
258
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 } ,"
252
260
" but it's already connected to another user."
253
261
)
254
- await ctx . reply (
262
+ await interaction . response . send_message (
255
263
f"{ aoc_name } is already tied to another account."
256
264
" Please contact an admin if you believe this is an error." ,
257
265
ephemeral = True ,
258
266
)
259
267
return
260
268
261
269
# 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 } ." )
266
277
else :
267
278
# 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 } ." )
271
282
else :
272
283
# 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
+ )
275
288
else :
276
- await ctx . reply (
289
+ await interaction . response . send_message (
277
290
"You have not linked an Advent of Code account."
278
291
" Please re-run the command with one specified."
279
292
)
280
293
281
294
@in_month (Month .NOVEMBER , Month .DECEMBER , Month .JANUARY , Month .FEBRUARY )
282
- @adventofcode_group .command (
295
+ @adventofcode_group .app_command . command (
283
296
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." ,
286
298
)
287
299
@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 :
289
301
"""
290
302
Unlink your Discord ID with your Advent of Code leaderboard name.
291
303
292
304
Deletes the entry that was Stored in the Redis cache.
293
305
"""
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
+ )
298
316
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
+ )
301
322
302
323
@in_month (Month .DECEMBER , Month .JANUARY , Month .FEBRUARY )
303
324
@adventofcode_group .command (
0 commit comments