Skip to content

Commit 8a326d3

Browse files
Merge main into bump-pycord
2 parents 6046c38 + 4ef6f86 commit 8a326d3

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

cogs/make_applicant.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,27 @@ class BaseMakeApplicantCog(TeXBotBaseCog):
3434
"""
3535

3636
async def _perform_make_applicant(
37-
self, ctx: "TeXBotApplicationContext", applicant_member: discord.Member
37+
self, ctx: "TeXBotApplicationContext", applicant_member_id: int
3838
) -> None:
3939
"""Perform the actual process of making the user into a group-applicant."""
4040
# 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
4141
main_guild: discord.Guild = ctx.bot.main_guild
4242
applicant_role: discord.Role = await ctx.bot.applicant_role
4343
guest_role: discord.Role = await ctx.bot.guest_role
4444

45+
applicant_member: discord.Member | None = main_guild.get_member(applicant_member_id)
46+
47+
if not applicant_member:
48+
await ctx.respond(
49+
content=(
50+
":information_source: "
51+
"No changes made. User cannot be made into an applicant "
52+
"because they have left the server :information_source:"
53+
),
54+
ephemeral=True,
55+
)
56+
return
57+
4558
if applicant_role in applicant_member.roles:
4659
await ctx.respond("User is already an applicant! Command aborted.")
4760
return
@@ -198,7 +211,7 @@ async def make_applicant(
198211
await self.command_send_error(ctx, message=member_id_not_integer_error.args[0])
199212
return
200213

201-
await self._perform_make_applicant(ctx, applicant_member)
214+
await self._perform_make_applicant(ctx, applicant_member.id)
202215

203216

204217
class MakeApplicantContextCommandsCog(BaseMakeApplicantCog):
@@ -208,7 +221,7 @@ class MakeApplicantContextCommandsCog(BaseMakeApplicantCog):
208221
@CommandChecks.check_interaction_user_has_committee_role
209222
@CommandChecks.check_interaction_user_in_main_guild
210223
async def user_make_applicant(
211-
self, ctx: "TeXBotApplicationContext", member: discord.Member
224+
self, ctx: "TeXBotApplicationContext", member: discord.Member | discord.User
212225
) -> None:
213226
"""
214227
Definition and callback response of the "make_applicant" user-context-command.
@@ -217,7 +230,7 @@ async def user_make_applicant(
217230
the "make_applicant" slash-command and thus gives the specified user the
218231
"Applicant" role and removes the "Guest" role if they have it.
219232
"""
220-
await self._perform_make_applicant(ctx, member)
233+
await self._perform_make_applicant(ctx, member.id)
221234

222235
@discord.message_command(name="Make Message Author Applicant")
223236
@CommandChecks.check_interaction_user_has_committee_role
@@ -232,19 +245,4 @@ async def message_make_applicant(
232245
the "make_applicant" slash-command and thus gives the specified user the
233246
"Applicant" role and removes the "Guest" role if they have it.
234247
"""
235-
try:
236-
member: discord.Member = await self.bot.get_member_from_str_id(
237-
str(message.author.id)
238-
)
239-
except ValueError:
240-
await ctx.respond(
241-
content=(
242-
":information_source: "
243-
"No changes made. User cannot be made into an applicant "
244-
"because they have left the server :information_source:"
245-
),
246-
ephemeral=True,
247-
)
248-
return
249-
250-
await self._perform_make_applicant(ctx, member)
248+
await self._perform_make_applicant(ctx, message.author.id)

cogs/strike.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ async def _confirm_increase_strike(
393393
)
394394

395395
async def _command_perform_strike(
396-
self, ctx: "TeXBotApplicationContext", strike_member: discord.Member
396+
self, ctx: "TeXBotApplicationContext", strike_member: discord.Member | discord.User
397397
) -> None:
398398
"""
399399
Perform the actual process of giving a member an additional strike.
@@ -1090,7 +1090,7 @@ async def _send_message_to_committee(
10901090
@CommandChecks.check_interaction_user_has_committee_role
10911091
@CommandChecks.check_interaction_user_in_main_guild
10921092
async def user_strike(
1093-
self, ctx: "TeXBotApplicationContext", member: discord.Member
1093+
self, ctx: "TeXBotApplicationContext", member: discord.Member | discord.User
10941094
) -> None:
10951095
"""Call the _strike command, providing the required command arguments."""
10961096
await self._command_perform_strike(ctx, strike_member=member)

0 commit comments

Comments
 (0)