Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions cogs/induct.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def get_random_welcome_message(
async def _perform_induction(
self,
ctx: "TeXBotApplicationContext",
induction_member: discord.Member,
induction_member_id: int,
*,
silent: bool,
) -> None:
Expand All @@ -188,6 +188,18 @@ async def _perform_induction(
main_guild: discord.Guild = self.bot.main_guild
guest_role: discord.Role = await self.bot.guest_role

induction_member: discord.Member | None = main_guild.get_member(induction_member_id)
if not induction_member:
await ctx.respond(
(
":information_source: No changes made. User cannot be inducted "
"because they have left the server "
":information_source:"
),
ephemeral=True,
)
return

await ctx.defer(ephemeral=True)
async with ctx.typing():
logger.debug("Inducting member %s, silent=%s", induction_member, silent)
Expand Down Expand Up @@ -346,7 +358,7 @@ async def induct(
await self.command_send_error(ctx, message=member_id_not_integer_error.args[0])
return

await self._perform_induction(ctx, induct_member, silent=silent)
await self._perform_induction(ctx, induct_member.id, silent=silent)


class InductContextCommandsCog(BaseInductCog):
Expand All @@ -356,7 +368,7 @@ class InductContextCommandsCog(BaseInductCog):
@CommandChecks.check_interaction_user_has_committee_role
@CommandChecks.check_interaction_user_in_main_guild
async def non_silent_user_induct(
self, ctx: "TeXBotApplicationContext", member: discord.Member
self, ctx: "TeXBotApplicationContext", member: discord.Member | discord.User
) -> None:
"""
Definition & callback response of the "non_silent_induct" user-context-command.
Expand All @@ -366,13 +378,13 @@ async def non_silent_user_induct(
Therefore, it will induct a given member into your group's Discord guild
by giving them the "Guest" role.
"""
await self._perform_induction(ctx, member, silent=False)
await self._perform_induction(ctx, member.id, silent=False)

@discord.user_command(name="Silently Induct User")
@CommandChecks.check_interaction_user_has_committee_role
@CommandChecks.check_interaction_user_in_main_guild
async def silent_user_induct(
self, ctx: "TeXBotApplicationContext", member: discord.Member
self, ctx: "TeXBotApplicationContext", member: discord.Member | discord.User
) -> None:
"""
Definition & callback response of the "silent_induct" user-context-command.
Expand All @@ -382,7 +394,7 @@ async def silent_user_induct(
Therefore, it will induct a given member into your group's Discord guild
by giving them the "Guest" role, only without broadcasting a welcome message.
"""
await self._perform_induction(ctx, member, silent=True)
await self._perform_induction(ctx, member.id, silent=True)

@discord.message_command(name="Induct Message Author")
@CommandChecks.check_interaction_user_has_committee_role
Expand Down Expand Up @@ -413,7 +425,7 @@ async def non_silent_message_induct(
)
return

await self._perform_induction(ctx, member, silent=False)
await self._perform_induction(ctx, member.id, silent=False)


class EnsureMembersInductedCommandCog(TeXBotBaseCog):
Expand Down
Loading