From 38f9b9c6764dfc01c325c193b8dd20700ce6adfd Mon Sep 17 00:00:00 2001 From: "Jacob P." Date: Fri, 19 Jun 2026 01:45:56 +0200 Subject: [PATCH] Skip empty THREAD_STARTER_MESSAGE placeholder in thread exports A thread created from a message has an empty THREAD_STARTER_MESSAGE (type 21) placeholder at the top of its history that just points back to the originating message. Now that the actual starter message is fetched and exported separately, this placeholder is redundant noise, so skip it. Co-Authored-By: Claude Opus 4.8 --- DiscordChatExporter.Core/Discord/Data/MessageKind.cs | 1 + DiscordChatExporter.Core/Exporting/ChannelExporter.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/DiscordChatExporter.Core/Discord/Data/MessageKind.cs b/DiscordChatExporter.Core/Discord/Data/MessageKind.cs index c2aba207..07eb431a 100644 --- a/DiscordChatExporter.Core/Discord/Data/MessageKind.cs +++ b/DiscordChatExporter.Core/Discord/Data/MessageKind.cs @@ -13,4 +13,5 @@ public enum MessageKind GuildMemberJoin = 7, ThreadCreated = 18, Reply = 19, + ThreadStarterMessage = 21, } diff --git a/DiscordChatExporter.Core/Exporting/ChannelExporter.cs b/DiscordChatExporter.Core/Exporting/ChannelExporter.cs index 00ae2476..a57bcc9f 100644 --- a/DiscordChatExporter.Core/Exporting/ChannelExporter.cs +++ b/DiscordChatExporter.Core/Exporting/ChannelExporter.cs @@ -120,6 +120,13 @@ public class ChannelExporter(DiscordClient discord) // Fetch the rest of the thread's history and yield messages one by one await foreach (var message in messages.WithCancellation(innerCancellationToken)) { + // A thread created from a message has an empty THREAD_STARTER_MESSAGE placeholder + // at the top of its history that merely points back to the originating message. + // It never carries any renderable content of its own and is superseded by the + // actual starter message fetched above, so skip it. + if (message.Kind == MessageKind.ThreadStarterMessage) + continue; + // Avoid exporting the starter message twice in case it's also returned as part // of the thread's own history. if (message.Id != starterMessage?.Id)