Skip to content
Merged
Show file tree
Hide file tree
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
38 changes: 18 additions & 20 deletions cogs/make_applicant.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,27 @@ class BaseMakeApplicantCog(TeXBotBaseCog):
"""

async def _perform_make_applicant(
self, ctx: "TeXBotApplicationContext", applicant_member: discord.Member
self, ctx: "TeXBotApplicationContext", applicant_member_id: int
) -> None:
"""Perform the actual process of making the user into a group-applicant."""
# NOTE: Shortcut accessors are placed at the top of the function so that the exceptions they raise are displayed before any further errors may be sent
main_guild: discord.Guild = ctx.bot.main_guild
applicant_role: discord.Role = await ctx.bot.applicant_role
guest_role: discord.Role = await ctx.bot.guest_role

applicant_member: discord.Member | None = main_guild.get_member(applicant_member_id)

if not applicant_member:
await ctx.respond(
content=(
":information_source: "
"No changes made. User cannot be made into an applicant "
"because they have left the server :information_source:"
),
ephemeral=True,
)
return

if applicant_role in applicant_member.roles:
await ctx.respond("User is already an applicant! Command aborted.")
return
Expand Down Expand Up @@ -196,7 +209,7 @@ async def make_applicant(
await self.command_send_error(ctx, message=member_id_not_integer_error.args[0])
return

await self._perform_make_applicant(ctx, applicant_member)
await self._perform_make_applicant(ctx, applicant_member.id)


class MakeApplicantContextCommandsCog(BaseMakeApplicantCog):
Expand All @@ -206,7 +219,7 @@ class MakeApplicantContextCommandsCog(BaseMakeApplicantCog):
@CommandChecks.check_interaction_user_has_committee_role
@CommandChecks.check_interaction_user_in_main_guild
async def user_make_applicant(
self, ctx: "TeXBotApplicationContext", member: discord.Member
self, ctx: "TeXBotApplicationContext", member: discord.Member | discord.User
) -> None:
"""
Definition and callback response of the "make_applicant" user-context-command.
Expand All @@ -215,7 +228,7 @@ async def user_make_applicant(
the "make_applicant" slash-command and thus gives the specified user the
"Applicant" role and removes the "Guest" role if they have it.
"""
await self._perform_make_applicant(ctx, member)
await self._perform_make_applicant(ctx, member.id)

@discord.message_command(name="Make Message Author Applicant")
@CommandChecks.check_interaction_user_has_committee_role
Expand All @@ -230,19 +243,4 @@ async def message_make_applicant(
the "make_applicant" slash-command and thus gives the specified user the
"Applicant" role and removes the "Guest" role if they have it.
"""
try:
member: discord.Member = await self.bot.get_member_from_str_id(
str(message.author.id)
)
except ValueError:
await ctx.respond(
content=(
":information_source: "
"No changes made. User cannot be made into an applicant "
"because they have left the server :information_source:"
),
ephemeral=True,
)
return

await self._perform_make_applicant(ctx, member)
await self._perform_make_applicant(ctx, message.author.id)
4 changes: 2 additions & 2 deletions cogs/strike.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ async def _confirm_increase_strike(
)

async def _command_perform_strike(
self, ctx: "TeXBotApplicationContext", strike_member: discord.Member
self, ctx: "TeXBotApplicationContext", strike_member: discord.Member | discord.User
) -> None:
"""
Perform the actual process of giving a member an additional strike.
Expand Down Expand Up @@ -1075,7 +1075,7 @@ async def _send_message_to_committee(
@CommandChecks.check_interaction_user_has_committee_role
@CommandChecks.check_interaction_user_in_main_guild
async def user_strike(
self, ctx: "TeXBotApplicationContext", member: discord.Member
self, ctx: "TeXBotApplicationContext", member: discord.Member | discord.User
) -> None:
"""Call the _strike command, providing the required command arguments."""
await self._command_perform_strike(ctx, strike_member=member)
Expand Down
Loading