@@ -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 )
@@ -348,7 +360,7 @@ async def induct(
348360 await self .command_send_error (ctx , message = member_id_not_integer_error .args [0 ])
349361 return
350362
351- await self ._perform_induction (ctx , induct_member , silent = silent )
363+ await self ._perform_induction (ctx , induct_member . id , silent = silent )
352364
353365
354366class InductContextCommandsCog (BaseInductCog ):
@@ -358,7 +370,7 @@ class InductContextCommandsCog(BaseInductCog):
358370 @CommandChecks .check_interaction_user_has_committee_role
359371 @CommandChecks .check_interaction_user_in_main_guild
360372 async def non_silent_user_induct (
361- self , ctx : "TeXBotApplicationContext" , member : discord .Member
373+ self , ctx : "TeXBotApplicationContext" , member : discord .Member | discord . User
362374 ) -> None :
363375 """
364376 Definition & callback response of the "non_silent_induct" user-context-command.
@@ -368,13 +380,13 @@ async def non_silent_user_induct(
368380 Therefore, it will induct a given member into your group's Discord guild
369381 by giving them the "Guest" role.
370382 """
371- await self ._perform_induction (ctx , member , silent = False )
383+ await self ._perform_induction (ctx , member . id , silent = False )
372384
373385 @discord .user_command (name = "Silently Induct User" )
374386 @CommandChecks .check_interaction_user_has_committee_role
375387 @CommandChecks .check_interaction_user_in_main_guild
376388 async def silent_user_induct (
377- self , ctx : "TeXBotApplicationContext" , member : discord .Member
389+ self , ctx : "TeXBotApplicationContext" , member : discord .Member | discord . User
378390 ) -> None :
379391 """
380392 Definition & callback response of the "silent_induct" user-context-command.
@@ -384,7 +396,7 @@ async def silent_user_induct(
384396 Therefore, it will induct a given member into your group's Discord guild
385397 by giving them the "Guest" role, only without broadcasting a welcome message.
386398 """
387- await self ._perform_induction (ctx , member , silent = True )
399+ await self ._perform_induction (ctx , member . id , silent = True )
388400
389401 @discord .message_command (name = "Induct Message Author" )
390402 @CommandChecks .check_interaction_user_has_committee_role
@@ -415,7 +427,7 @@ async def non_silent_message_induct(
415427 )
416428 return
417429
418- await self ._perform_induction (ctx , member , silent = False )
430+ await self ._perform_induction (ctx , member . id , silent = False )
419431
420432
421433class EnsureMembersInductedCommandCog (TeXBotBaseCog ):
0 commit comments