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
30 changes: 18 additions & 12 deletions bot/exts/recruitment/talentpool/_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ async def archive_vote(self, message: PartialMessage, passed: bool) -> None:
"""Archive this vote to #nomination-archive."""
message = await message.fetch()

# Thread channel IDs are the same as the message ID of the parent message.
nomination_thread = message.guild.get_thread(message.id)
if not nomination_thread:
try:
nomination_thread = await message.guild.fetch_channel(message.id)
except NotFound:
log.warning(f"Could not find a thread linked to {message.channel.id}-{message.id}")

# We consider the first message in the nomination to contain the user ping, username#discrim, and fixed text
messages = [message]
if not NOMINATION_MESSAGE_REGEX.search(message.content):
Expand Down Expand Up @@ -327,9 +335,15 @@ async def archive_vote(self, message: PartialMessage, passed: bool) -> None:
colour = Colours.soft_green if passed else Colours.soft_red
timestamp = datetime.now(tz=UTC).strftime("%Y/%m/%d")

if nomination_thread:
thread_jump = f"[Jump to vote thread]({nomination_thread.jump_url})"
else:
thread_jump = "Failed to get thread"

embed_content = (
f"{result} on {timestamp}\n"
f"With {reviewed} {Emojis.ducky_dave} {upvotes} :+1: {downvotes} :-1:\n\n"
f"With {reviewed} {Emojis.ducky_dave} {upvotes} :+1: {downvotes} :-1:\n"
f"{thread_jump}\n\n"
f"{stripped_content}"
)

Expand All @@ -348,21 +362,13 @@ async def archive_vote(self, message: PartialMessage, passed: bool) -> None:
colour=colour
))

# Thread channel IDs are the same as the message ID of the parent message.
nomination_thread = message.guild.get_thread(message.id)
if not nomination_thread:
try:
nomination_thread = await message.guild.fetch_channel(message.id)
except NotFound:
log.warning(f"Could not find a thread linked to {message.channel.id}-{message.id}")
return

for message_ in messages:
with contextlib.suppress(NotFound):
await message_.delete()

with contextlib.suppress(NotFound):
await nomination_thread.edit(archived=True)
if nomination_thread:
with contextlib.suppress(NotFound):
await nomination_thread.edit(archived=True)

async def _construct_review_body(self, member: Member) -> str:
"""Formats the body of the nomination, with details of activity, infractions, and previous nominations."""
Expand Down