11
2- from  discord .ext .commands  import  Cog , Bot ,  command 
2+ from  discord .ext .commands  import  Cog , Bot 
33from  discord .ui  import  Modal , TextInput 
4+ from  discord .ext  import  commands 
45from  discord  import  app_commands 
56
67from  app .common .database .objects  import  DBUser 
@@ -17,35 +18,34 @@ def __init__(self) -> None:
1718        super ().__init__ ()
1819        self .member_role  =  discord .utils .get (self .guild .roles , name = "Member" )
1920
20-     @app_commands .command (name = "link" , description = "Link your account to Titanic!" ) 
21-     @app_commands .describe (username = "Your Titanic! username" ) 
22-     async  def  link_account (self , interaction : discord .Interaction , username : str ) ->  None :
23-         if  existing_user  :=  await  self .resolve_user (interaction .user .id ):
24-             return  await  interaction .response .send_message (
21+     @commands .hybrid_command ("link" , description = "Link your account to Titanic!" , hidden = True ) 
22+     async  def  link_account (self , ctx : commands .Context , username : str ) ->  None :
23+         if  existing_user  :=  await  self .resolve_user (ctx .author .id ):
24+             return  await  ctx .send (
2525                "Your account is already linked to Titanic! " 
2626                "Use /unlink to unlink your current account." ,
2727                ephemeral = True 
2828            )
2929
3030        if  not  (target_user  :=  await  self .resolve_user_by_name (username )):
31-             return  await  interaction . response . send_message (
31+             return  await  ctx . send (
3232                "No user found with that name." ,
3333                ephemeral = True 
3434            )
3535
3636        if  target_user .discord_id :
37-             return  await  interaction . response . send_message (
37+             return  await  ctx . send (
3838                "This user is already linked to another Discord account." ,
3939                ephemeral = True 
4040            )
4141
4242        if  not  status .exists (target_user .id ):
43-             return  await  interaction . response . send_message (
43+             return  await  ctx . send (
4444                "Please log into the game and try again!" ,
4545                ephemeral = True 
4646            )
4747
48-         self .logger .info (f'[{ interaction . user }  ] -> Starting linking process...' )
48+         self .logger .info (f'[{ ctx . author }  ] -> Starting linking process...' )
4949
5050        # Generate random 6-letter code which will be sent over DMs 
5151        code  =  '' .join (random .choices (string .ascii_lowercase , k = 6 ))
@@ -61,16 +61,16 @@ async def link_account(self, interaction: discord.Interaction, username: str) ->
6161        )
6262        embed .set_footer (text = "This message is only visible to you." )
6363
64-         await  interaction . response . send_message (
64+         await  ctx . send (
6565            view = LinkingView (code , target_user , self ),
6666            embed = embed ,
6767            ephemeral = True 
6868        )
6969
70-     @app_commands . command ( name = "unlink" , description = "Unlink your account from Titanic!" ) 
71-     async  def  unlink_account (self , interaction :  discord . Interaction ) ->  None :
72-         if  not  (linked_user  :=  await  self .resolve_user (interaction . user .id )):
73-             return  await  interaction . response . send_message (
70+     @commands . hybrid_command ( "unlink" , description = "Unlink your account from Titanic!" ,  hidden = True ) 
71+     async  def  unlink_account (self , ctx :  commands . Context ) ->  None :
72+         if  not  (linked_user  :=  await  self .resolve_user (ctx . author .id )):
73+             return  await  ctx . send (
7474                "Your account is not linked to Titanic!" ,
7575                ephemeral = True 
7676            )
@@ -79,8 +79,7 @@ async def unlink_account(self, interaction: discord.Interaction) -> None:
7979            linked_user .id ,
8080            {"discord_id" : None }
8181        )
82- 
83-         await  interaction .response .send_message (
82+         await  ctx .send (
8483            "You have successfully unlinked your account from Titanic!" ,
8584            ephemeral = True 
8685        )
0 commit comments