@@ -153,20 +153,31 @@ async def create_private_clash_of_code(
153153 )
154154 except HTTPError as error :
155155 if error .data ["id" ] in (500 , 501 ):
156- raise LoginRequired () from None
156+ raise LoginRequired (error . data . get ( "message" , "" ) ) from None
157157 raise # pragma: no cover
158158
159159 return await self .get_clash_of_code (data ["publicHandle" ])
160160
161- async def join_private_clash_of_code (self , handle : str ) -> ClashOfCode :
161+ async def join_private_clash_of_code (
162+ self , clash_of_code : typing .Union [ClashOfCode , str ]
163+ ) -> ClashOfCode :
164+ if not self .logged_in :
165+ raise LoginRequired ()
166+
167+ handle = (
168+ clash_of_code
169+ if isinstance (clash_of_code , str )
170+ else clash_of_code .public_handle
171+ )
172+
162173 if not CLASH_OF_CODE_HANDLE_REGEX .match (handle ):
163174 raise ValueError (
164175 f"Clash of Code handle { handle !r} isn't in the good format "
165176 "(regex: [0-9]{7}[0-9a-f]{32})."
166177 )
167178
168179 try :
169- data = await self ._state .http .join_clash_of_code_by_handle (
180+ await self ._state .http .join_clash_of_code_by_handle (
170181 self .codingamer .id , handle
171182 )
172183 except HTTPError as error :
@@ -181,7 +192,7 @@ async def join_private_clash_of_code(self, handle: str) -> ClashOfCode:
181192 )
182193
183194 raise # pragma: no cover
184- return ClashOfCode ( self ._state , data )
195+ return await self .get_clash_of_code ( handle )
185196
186197 # --------------------------------------------------------------------------
187198 # Language IDs
0 commit comments