@@ -179,7 +179,7 @@ async def get_random_welcome_message(
179179 async def _perform_induction (
180180 self ,
181181 ctx : "TeXBotApplicationContext" ,
182- induction_member : discord . Member ,
182+ induction_member_id : int ,
183183 * ,
184184 silent : bool ,
185185 ) -> None :
@@ -188,6 +188,18 @@ async def _perform_induction(
188188 main_guild : discord .Guild = self .bot .main_guild
189189 guest_role : discord .Role = await self .bot .guest_role
190190
191+ induction_member : discord .Member | None = main_guild .get_member (induction_member_id )
192+ if not induction_member :
193+ await ctx .respond (
194+ (
195+ ":information_source: No changes made. User cannot be inducted "
196+ "because they have left the server "
197+ ":information_source:"
198+ ),
199+ ephemeral = True ,
200+ )
201+ return
202+
191203 await ctx .defer (ephemeral = True )
192204 async with ctx .typing ():
193205 logger .debug ("Inducting member %s, silent=%s" , induction_member , silent )
@@ -346,7 +358,7 @@ async def induct(
346358 await self .command_send_error (ctx , message = member_id_not_integer_error .args [0 ])
347359 return
348360
349- await self ._perform_induction (ctx , induct_member , silent = silent )
361+ await self ._perform_induction (ctx , induct_member . id , silent = silent )
350362
351363
352364class InductContextCommandsCog (BaseInductCog ):
@@ -356,7 +368,7 @@ class InductContextCommandsCog(BaseInductCog):
356368 @CommandChecks .check_interaction_user_has_committee_role
357369 @CommandChecks .check_interaction_user_in_main_guild
358370 async def non_silent_user_induct (
359- self , ctx : "TeXBotApplicationContext" , member : discord .Member
371+ self , ctx : "TeXBotApplicationContext" , member : discord .Member | discord . User
360372 ) -> None :
361373 """
362374 Definition & callback response of the "non_silent_induct" user-context-command.
@@ -366,13 +378,13 @@ async def non_silent_user_induct(
366378 Therefore, it will induct a given member into your group's Discord guild
367379 by giving them the "Guest" role.
368380 """
369- await self ._perform_induction (ctx , member , silent = False )
381+ await self ._perform_induction (ctx , member . id , silent = False )
370382
371383 @discord .user_command (name = "Silently Induct User" )
372384 @CommandChecks .check_interaction_user_has_committee_role
373385 @CommandChecks .check_interaction_user_in_main_guild
374386 async def silent_user_induct (
375- self , ctx : "TeXBotApplicationContext" , member : discord .Member
387+ self , ctx : "TeXBotApplicationContext" , member : discord .Member | discord . User
376388 ) -> None :
377389 """
378390 Definition & callback response of the "silent_induct" user-context-command.
@@ -382,7 +394,7 @@ async def silent_user_induct(
382394 Therefore, it will induct a given member into your group's Discord guild
383395 by giving them the "Guest" role, only without broadcasting a welcome message.
384396 """
385- await self ._perform_induction (ctx , member , silent = True )
397+ await self ._perform_induction (ctx , member . id , silent = True )
386398
387399 @discord .message_command (name = "Induct Message Author" )
388400 @CommandChecks .check_interaction_user_has_committee_role
@@ -413,7 +425,7 @@ async def non_silent_message_induct(
413425 )
414426 return
415427
416- await self ._perform_induction (ctx , member , silent = False )
428+ await self ._perform_induction (ctx , member . id , silent = False )
417429
418430
419431class EnsureMembersInductedCommandCog (TeXBotBaseCog ):
0 commit comments