From 99ba58934b3443f00148136091268a50ffe7abdd Mon Sep 17 00:00:00 2001 From: wookie184 Date: Wed, 12 Apr 2023 18:01:04 +0100 Subject: [PATCH 1/2] Include thread jump url in nomination archive message --- bot/exts/recruitment/talentpool/_review.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index be9456c379..194590d6ba 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -282,6 +282,7 @@ async def make_review(self, nomination: Nomination) -> tuple[str, Emoji | None, async def archive_vote(self, message: PartialMessage, passed: bool) -> None: """Archive this vote to #nomination-archive.""" message = await message.fetch() + thread = message.channel.get_thread(message.id) # We consider the first message in the nomination to contain the user ping, username#discrim, and fixed text messages = [message] @@ -326,10 +327,12 @@ async def archive_vote(self, message: PartialMessage, passed: bool) -> None: result = f"**Passed** {Emojis.incident_actioned}" if passed else f"**Rejected** {Emojis.incident_unactioned}" colour = Colours.soft_green if passed else Colours.soft_red timestamp = datetime.now(tz=UTC).strftime("%Y/%m/%d") + thread_jump = f"[Jump to vote thread]({thread.jump_url})" if thread else "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}" ) From cf8409463390a2bdb03720bed912ff61a36fa4ae Mon Sep 17 00:00:00 2001 From: wookie184 Date: Thu, 13 Apr 2023 18:18:46 +0100 Subject: [PATCH 2/2] Use existing thread variable --- bot/exts/recruitment/talentpool/_review.py | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index 194590d6ba..5bd63f65e3 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -282,7 +282,14 @@ async def make_review(self, nomination: Nomination) -> tuple[str, Emoji | None, async def archive_vote(self, message: PartialMessage, passed: bool) -> None: """Archive this vote to #nomination-archive.""" message = await message.fetch() - thread = message.channel.get_thread(message.id) + + # 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] @@ -327,7 +334,11 @@ async def archive_vote(self, message: PartialMessage, passed: bool) -> None: result = f"**Passed** {Emojis.incident_actioned}" if passed else f"**Rejected** {Emojis.incident_unactioned}" colour = Colours.soft_green if passed else Colours.soft_red timestamp = datetime.now(tz=UTC).strftime("%Y/%m/%d") - thread_jump = f"[Jump to vote thread]({thread.jump_url})" if thread else "Failed to get thread" + + 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" @@ -351,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."""