From 742382bdbc6ac984705c8db640d8a9384df0f649 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Fri, 5 Jun 2026 11:17:10 -0700 Subject: [PATCH 1/2] Improves the way the first message is fetched in new forums --- techsupport_bot/commands/forum.py | 64 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/techsupport_bot/commands/forum.py b/techsupport_bot/commands/forum.py index 7e12a151..57e82a12 100644 --- a/techsupport_bot/commands/forum.py +++ b/techsupport_bot/commands/forum.py @@ -502,38 +502,40 @@ async def on_thread_create(self: Self, thread: discord.Thread) -> None: return # Check if the thread body is disallowed - messages = [message async for message in thread.history(limit=5)] - if messages: - body = messages[-1].content - disallowed_body_patterns = create_regex_list( - config.extensions.forum.body_regex_list.value + message = await thread.fetch_message(thread.id) + body = message.clean_content + if not body: + body = "" + + disallowed_body_patterns = create_regex_list( + config.extensions.forum.body_regex_list.value + ) + if any(pattern.search(body) for pattern in disallowed_body_patterns): + await mark_thread( + thread, + config, + self.thread_ID_closed, + "rejected", + reason=( + "Your thread doesn't meet our posting requirements. " + "Please make sure you have a well written title and a detailed body." + ), ) - if any(pattern.search(body) for pattern in disallowed_body_patterns): - await mark_thread( - thread, - config, - self.thread_ID_closed, - "rejected", - reason=( - "Your thread doesn't meet our posting requirements. " - "Please make sure you have a well written title and a detailed body." - ), - ) - return - if body.lower() == thread.name.lower() or len(body.lower()) < len( - thread.name.lower() - ): - await mark_thread( - thread, - config, - self.thread_ID_closed, - "rejected", - reason=( - "Your thread doesn't meet our posting requirements. " - "Please make sure you have a well written title and a detailed body." - ), - ) - return + return + if body.lower() == thread.name.lower() or len(body.lower()) < len( + thread.name.lower() + ): + await mark_thread( + thread, + config, + self.thread_ID_closed, + "rejected", + reason=( + "Your thread doesn't meet our posting requirements. " + "Please make sure you have a well written title and a detailed body." + ), + ) + return # Check if the thread creator has an existing open thread for existing_thread in channel.threads: From 370a260029ad795422f0dd81ba3e21e3a2f433e3 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Sun, 7 Jun 2026 14:33:47 -0700 Subject: [PATCH 2/2] Fix bug --- techsupport_bot/commands/forum.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/techsupport_bot/commands/forum.py b/techsupport_bot/commands/forum.py index 02a32d80..83f603fa 100644 --- a/techsupport_bot/commands/forum.py +++ b/techsupport_bot/commands/forum.py @@ -429,7 +429,6 @@ async def on_thread_create(self: Self, thread: discord.Thread) -> None: if any(pattern.search(body) for pattern in disallowed_body_patterns): await mark_thread( thread, - config, self.thread_ID_closed, "rejected", reason=( @@ -443,7 +442,6 @@ async def on_thread_create(self: Self, thread: discord.Thread) -> None: ): await mark_thread( thread, - config, self.thread_ID_closed, "rejected", reason=(