diff --git a/techsupport_bot/commands/forum.py b/techsupport_bot/commands/forum.py index 57d5c956..83f603fa 100644 --- a/techsupport_bot/commands/forum.py +++ b/techsupport_bot/commands/forum.py @@ -418,36 +418,38 @@ 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( - configuration.get_config_entry(thread.guild.id, "forum_body_regex_list") + message = await thread.fetch_message(thread.id) + body = message.clean_content + if not body: + body = "" + + disallowed_body_patterns = create_regex_list( + configuration.get_config_entry(thread.guild.id, "forum_body_regex_list") + ) + if any(pattern.search(body) for pattern in disallowed_body_patterns): + await mark_thread( + thread, + 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, - 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, - 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, + 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: