diff options
author | 2023-04-14 14:17:17 +0100 | |
---|---|---|
committer | 2023-04-14 13:17:17 +0000 | |
commit | ade95c4685bb273568bc83d448cfda46398a4077 (patch) | |
tree | f7c81db354aaeea04ff51ca04fb05d3e2ab6d00c | |
parent | Fix readme badges for CI status (#2537) (diff) |
Include thread jump url in nomination archive message (#2536)
* Include thread jump url in nomination archive message
* Use existing thread variable
-rw-r--r-- | bot/exts/recruitment/talentpool/_review.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index be9456c37..5bd63f65e 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -283,6 +283,14 @@ class Reviewer: """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): @@ -327,9 +335,15 @@ class Reviewer: 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}" ) @@ -348,21 +362,13 @@ class Reviewer: 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.""" |