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 <noreply@anthropic.com>
This commit is contained in:
Jacob P. 2026-06-19 01:45:56 +02:00
parent f9a800e667
commit 38f9b9c676
No known key found for this signature in database
GPG key ID: CC10D6AE715DAEDF
2 changed files with 8 additions and 0 deletions

View file

@ -13,4 +13,5 @@ public enum MessageKind
GuildMemberJoin = 7,
ThreadCreated = 18,
Reply = 19,
ThreadStarterMessage = 21,
}

View file

@ -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)