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)