diff options
author | 2022-12-29 01:07:38 +0100 | |
---|---|---|
committer | 2022-12-28 16:07:38 -0800 | |
commit | 5bde6089203c95b971a259bb23e1f3569bff128a (patch) | |
tree | 005dcc3399c8f8565802ceeb6d2a86113f32a1f0 | |
parent | Merge pull request #2365 from python-discord/shenanigansd-patch-1 (diff) |
Link previous nomination threads to a user nomination's history (#2319)
Co-authored-by: Amrou Bellalouna <[email protected]>
Closes https://github.com/python-discord/bot/issues/2304
-rw-r--r-- | bot/exts/recruitment/talentpool/_api.py | 4 | ||||
-rw-r--r-- | bot/exts/recruitment/talentpool/_cog.py | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/bot/exts/recruitment/talentpool/_api.py b/bot/exts/recruitment/talentpool/_api.py index fee23826d..c00c8c09c 100644 --- a/bot/exts/recruitment/talentpool/_api.py +++ b/bot/exts/recruitment/talentpool/_api.py @@ -23,6 +23,7 @@ class Nomination(BaseModel): ended_at: datetime | None entries: list[NominationEntry] reviewed: bool + thread_id: int | None class NominationAPI: @@ -65,6 +66,7 @@ class NominationAPI: end_reason: str | None = None, active: bool | None = None, reviewed: bool | None = None, + thread_id: int | None = None, ) -> Nomination: """ Edit a nomination. @@ -78,6 +80,8 @@ class NominationAPI: data["active"] = active if reviewed is not None: data["reviewed"] = reviewed + if thread_id is not None: + data["thread_id"] = thread_id result = await self.site_api.patch(f"bot/nominations/{nomination_id}", json=data) return Nomination.parse_obj(result) diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py index dbc3ea538..a41d9e8c5 100644 --- a/bot/exts/recruitment/talentpool/_cog.py +++ b/bot/exts/recruitment/talentpool/_cog.py @@ -17,6 +17,7 @@ from bot.exts.recruitment.talentpool._review import Reviewer from bot.log import get_logger from bot.pagination import LinePaginator from bot.utils import time +from bot.utils.channel import get_or_fetch_channel from bot.utils.members import get_or_fetch_member from ._api import Nomination, NominationAPI @@ -489,6 +490,17 @@ class TalentPool(Cog, name="Talentpool"): entries_string = "\n\n".join(entries) start_date = time.discord_timestamp(nomination.inserted_at) + + thread_jump_url = "*Not created*" + + if nomination.thread_id: + try: + thread = await get_or_fetch_channel(nomination.thread_id) + except discord.HTTPException: + thread_jump_url = "*Not found*" + else: + thread_jump_url = f'[Jump to thread!]({thread.jump_url})' + if nomination.active: lines = textwrap.dedent( f""" @@ -496,6 +508,7 @@ class TalentPool(Cog, name="Talentpool"): Status: **Active** Date: {start_date} Nomination ID: `{nomination.id}` + Nomination vote thread: {thread_jump_url} {entries_string} =============== @@ -509,6 +522,7 @@ class TalentPool(Cog, name="Talentpool"): Status: Inactive Date: {start_date} Nomination ID: `{nomination.id}` + Nomination vote thread: {thread_jump_url} {entries_string} |