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
56 changes: 28 additions & 28 deletions bot/exts/recruitment/talentpool/_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,33 @@ async def autoreview_enable(self, ctx: Context) -> None:
manually reviewed with the `tp post_review <user_id>` command.
"""
if await self.autoreview_enabled():
await ctx.send(":x: Autoreview is already enabled")
await ctx.send(":x: Autoreview is already enabled.")
return

await self.talentpool_settings.set(AUTOREVIEW_ENABLED_KEY, True)
await self.reviewer.reschedule_reviews()
await ctx.send(":white_check_mark: Autoreview enabled")
await ctx.send(":white_check_mark: Autoreview enabled.")

@nomination_autoreview_group.command(name="disable", aliases=("off",))
@has_any_role(Roles.admins)
async def autoreview_disable(self, ctx: Context) -> None:
"""Disable automatic posting of reviews."""
if not await self.autoreview_enabled():
await ctx.send(":x: Autoreview is already disabled")
await ctx.send(":x: Autoreview is already disabled.")
return

await self.talentpool_settings.set(AUTOREVIEW_ENABLED_KEY, False)
self.reviewer.cancel_all()
await ctx.send(":white_check_mark: Autoreview disabled")
await ctx.send(":white_check_mark: Autoreview disabled.")

@nomination_autoreview_group.command(name="status")
@has_any_role(*MODERATION_ROLES)
async def autoreview_status(self, ctx: Context) -> None:
"""Show whether automatic posting of reviews is enabled or disabled."""
if await self.autoreview_enabled():
await ctx.send("Autoreview is currently enabled")
await ctx.send("Autoreview is currently enabled.")
else:
await ctx.send("Autoreview is currently disabled")
await ctx.send("Autoreview is currently disabled.")

@nomination_group.command(
name="nominees",
Expand Down Expand Up @@ -240,7 +240,7 @@ async def nominate_command(self, ctx: Context, user: MemberOrUser, *, reason: st
f"Use `{BotConfig.prefix}tp forcenominate` to override this check."
)
else:
await ctx.send(f":x: Nominations must be run in the <#{Channels.nominations}> channel")
await ctx.send(f":x: Nominations must be run in the <#{Channels.nominations}> channel.")
return

await self._nominate_user(ctx, user, reason)
Expand All @@ -256,11 +256,11 @@ async def _nominate_user(self, ctx: Context, user: MemberOrUser, reason: str) ->
return

if not await self.refresh_cache():
await ctx.send(f":x: Failed to update the cache; can't add {user}")
await ctx.send(f":x: Failed to update the cache; can't add {user.mention}.")
return

if len(reason) > REASON_MAX_CHARS:
await ctx.send(f":x: Maximum allowed characters for the reason is {REASON_MAX_CHARS}.")
await ctx.send(f":x: The reason's length must not exceed {REASON_MAX_CHARS} characters.")
return

# Manual request with `raise_for_status` as False because we want the actual response
Expand All @@ -279,9 +279,9 @@ async def _nominate_user(self, ctx: Context, user: MemberOrUser, reason: str) ->

if resp.status == 400:
if response_data.get('user', False):
await ctx.send(":x: The specified user can't be found in the database tables")
await ctx.send(f":x: {user.mention} can't be found in the database tables.")
elif response_data.get('actor', False):
await ctx.send(":x: You have already nominated this user")
await ctx.send(f":x: You have already nominated {user.mention}.")

return
else:
Expand All @@ -292,9 +292,7 @@ async def _nominate_user(self, ctx: Context, user: MemberOrUser, reason: str) ->
if await self.autoreview_enabled() and user.id not in self.reviewer:
self.reviewer.schedule_review(user.id)

msg = f"✅ The nomination for {user.mention} has been added to the talent pool"

await ctx.send(msg)
await ctx.send(f"✅ The nomination for {user.mention} has been added to the talent pool.")

@nomination_group.command(name='history', aliases=('info', 'search'))
@has_any_role(*MODERATION_ROLES)
Expand All @@ -308,7 +306,7 @@ async def history_command(self, ctx: Context, user: MemberOrUser) -> None:
}
)
if not result:
await ctx.send(":warning: This user has never been nominated")
await ctx.send(f":warning: {user.mention} has never been nominated.")
return

embed = Embed(
Expand All @@ -334,13 +332,13 @@ async def end_nomination_command(self, ctx: Context, user: MemberOrUser, *, reas
Providing a `reason` is required.
"""
if len(reason) > REASON_MAX_CHARS:
await ctx.send(f":x: Maximum allowed characters for the end reason is {REASON_MAX_CHARS}.")
await ctx.send(f":x: The reason's length must not exceed {REASON_MAX_CHARS} characters.")
return

if await self.end_nomination(user.id, reason):
await ctx.send(f":white_check_mark: Successfully un-nominated {user}")
await ctx.send(f":white_check_mark: Successfully un-nominated {user.mention}.")
else:
await ctx.send(":x: The specified user does not have an active nomination")
await ctx.send(f":x: {user.mention} doesn't have an active nomination.")

@nomination_group.group(name='edit', aliases=('e',), invoke_without_command=True)
@has_any_role(*STAFF_ROLES)
Expand Down Expand Up @@ -375,7 +373,7 @@ async def edit_reason_command(

if not any(role.id in MODERATION_ROLES for role in ctx.author.roles):
if ctx.channel.id != Channels.nominations:
await ctx.send(f":x: Nomination edits must be run in the <#{Channels.nominations}> channel")
await ctx.send(f":x: Nomination edits must be run in the <#{Channels.nominations}> channel.")
return

if nominator != ctx.author or isinstance(nominee_or_nomination_id, int):
Expand All @@ -402,29 +400,29 @@ async def _edit_nomination_reason(
) -> None:
"""Edit a nomination reason in the database after validating the input."""
if len(reason) > REASON_MAX_CHARS:
await ctx.send(f":x: Maximum allowed characters for the reason is {REASON_MAX_CHARS}.")
await ctx.send(f":x: The reason's length must not exceed {REASON_MAX_CHARS} characters.")
return
if isinstance(target, int):
nomination_id = target
else:
if nomination := self.cache.get(target.id):
nomination_id = nomination["id"]
else:
await ctx.send("No active nomination found for that member.")
await ctx.send(f":x: {target.mention} doesn't have an active nomination.")
return

try:
nomination = await self.bot.api_client.get(f"bot/nominations/{nomination_id}")
except ResponseCodeError as e:
if e.response.status == 404:
log.trace(f"Nomination API 404: Can't find a nomination with id {nomination_id}")
await ctx.send(f":x: Can't find a nomination with id `{nomination_id}`")
await ctx.send(f":x: Can't find a nomination with id `{nomination_id}`.")
return
else:
raise

if not nomination["active"]:
await ctx.send(":x: Can't edit the reason of an inactive nomination.")
await ctx.send(f":x: <@{nomination['user']}> doesn't have an active nomination.")
return

if not any(entry["actor"] == actor.id for entry in nomination["entries"]):
Expand All @@ -438,28 +436,30 @@ async def _edit_nomination_reason(
json={"actor": actor.id, "reason": reason}
)
await self.refresh_cache() # Update cache
await ctx.send(":white_check_mark: Successfully updated nomination reason.")
await ctx.send(f":white_check_mark: Updated the nomination reason for <@{nomination['user']}>.")

@nomination_edit_group.command(name='end_reason')
@has_any_role(*MODERATION_ROLES)
async def edit_end_reason_command(self, ctx: Context, nomination_id: int, *, reason: str) -> None:
"""Edits the unnominate reason for the nomination with the given `id`."""
if len(reason) > REASON_MAX_CHARS:
await ctx.send(f":x: Maximum allowed characters for the end reason is {REASON_MAX_CHARS}.")
await ctx.send(f":x: The reason's length must not exceed {REASON_MAX_CHARS} characters.")
return

try:
nomination = await self.bot.api_client.get(f"bot/nominations/{nomination_id}")
except ResponseCodeError as e:
if e.response.status == 404:
log.trace(f"Nomination API 404: Can't find a nomination with id {nomination_id}")
await ctx.send(f":x: Can't find a nomination with id `{nomination_id}`")
await ctx.send(f":x: Can't find a nomination with id `{nomination_id}`.")
return
else:
raise

if nomination["active"]:
await ctx.send(":x: Can't edit the end reason of an active nomination.")
await ctx.send(
f":x: Can't edit the nomination end reason for <@{nomination['user']}> because it's still active."
)
return

log.trace(f"Changing end reason for nomination with id {nomination_id} to {repr(reason)}")
Expand All @@ -469,7 +469,7 @@ async def edit_end_reason_command(self, ctx: Context, nomination_id: int, *, rea
json={"end_reason": reason}
)
await self.refresh_cache() # Update cache.
await ctx.send(":white_check_mark: Updated the end reason of the nomination!")
await ctx.send(f":white_check_mark: Updated the nomination end reason for <@{nomination['user']}>.")

@nomination_group.command(aliases=('mr',))
@has_any_role(*MODERATION_ROLES)
Expand Down