diff options
author | 2022-12-31 17:52:54 +0100 | |
---|---|---|
committer | 2022-12-31 16:52:54 +0000 | |
commit | 870cf7fb25152afbe31f2a2c4d3cc0f26a714d41 (patch) | |
tree | f94a4a91960bc20bf8a3f023a029ebbd63d424e7 | |
parent | Link previous nomination threads to a user nomination's history (#2319) (diff) |
Link previous nomination threads to a user nomination's history (#2373)
* add thread_id to pydantic model
* add thread mentions to review history
* add list of threads to a review's markdown file
* replace thread mention with jump url
* add style to thread not found message
* use get_or_fetch_channel to look from thread
* use jump_url in the review markdown file
* catch HttpException when threads are not found
* remove link syntaxt for previous nomination threads upon getting a review
* check for whether thread_id is null or not in history nominations
Co-authored-by: Amrou Bellalouna <[email protected]>
-rw-r--r-- | bot/exts/recruitment/talentpool/_review.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index 876f95369..f41e08fe1 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -8,6 +8,7 @@ from collections import Counter from datetime import datetime, timedelta, timezone from typing import List, Optional, Union +import discord from discord import Embed, Emoji, Member, Message, NotFound, PartialMessage, TextChannel from pydis_core.site_api import ResponseCodeError @@ -16,6 +17,7 @@ from bot.constants import Channels, Colours, Emojis, Guild, Roles from bot.exts.recruitment.talentpool._api import Nomination, NominationAPI from bot.log import get_logger from bot.utils import time +from bot.utils.channel import get_or_fetch_channel from bot.utils.members import get_or_fetch_member from bot.utils.messages import count_unique_users_reaction, pin_no_system_message @@ -180,7 +182,7 @@ class Reviewer: ) message = await thread.send(f"<@&{Roles.mod_team}> <@&{Roles.admins}>") - await self.api.edit_nomination(nomination.id, reviewed=True) + await self.api.edit_nomination(nomination.id, reviewed=True, thread_id=thread.id) bump_cog: ThreadBumper = self.bot.get_cog("ThreadBumper") if bump_cog: @@ -433,11 +435,30 @@ class Reviewer: nomination_times = f"{num_entries} times" if num_entries > 1 else "once" rejection_times = f"{len(history)} times" if len(history) > 1 else "once" + thread_jump_urls = [] + + for nomination in history: + if nomination.thread_id is None: + continue + try: + thread = await get_or_fetch_channel(nomination.thread_id) + except discord.HTTPException: + # Nothing to do here + pass + else: + thread_jump_urls.append(thread.jump_url) + + if not thread_jump_urls: + nomination_vote_threads = "No nomination threads have been found for this user." + else: + nomination_vote_threads = ", ".join(thread_jump_urls) + end_time = time.format_relative(history[0].ended_at) review = ( f"They were nominated **{nomination_times}** before" f", but their nomination was called off **{rejection_times}**." + f"\nList of all of their nomination threads: {nomination_vote_threads}" f"\nThe last one ended {end_time} with the reason: {history[0].end_reason}" ) |