From 89a2dabf2d74f0dc98ef5fd8140b0c51032ad375 Mon Sep 17 00:00:00 2001 From: Wave Dev <66224387+wavedevgit@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:15:57 +0000 Subject: [PATCH] feat: add x-super-properties header The x-super-properties header is an important header that contains info about the client with a launch signature. if this header is not provided, discord may flag requests and cause accounts to be banned/restricted --- .../Discord/DiscordClient.cs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Core/Discord/DiscordClient.cs b/DiscordChatExporter.Core/Discord/DiscordClient.cs index c3846136..bd13cb17 100644 --- a/DiscordChatExporter.Core/Discord/DiscordClient.cs +++ b/DiscordChatExporter.Core/Discord/DiscordClient.cs @@ -33,17 +33,41 @@ public class DiscordClient( ) { return await Http.ResponseResiliencePipeline.ExecuteAsync( - async innerCancellationToken => + async innerCancellationToken => { using var request = new HttpRequestMessage(HttpMethod.Get, new Uri(_baseUri, url)); - // Don't validate because the token can have special characters - // https://github.com/Tyrrrz/DiscordChatExporter/issues/828 + // Authorization header request.Headers.TryAddWithoutValidation( "Authorization", tokenKind == TokenKind.Bot ? $"Bot {token}" : token ); + // add browser headers like x-super-properties and user-agent + // this is really important as discord flags requests that dont have valid xsp header + if (tokenKind != TokenKind.Bot) + { + try + { + var headersJson = await Http.Client.GetStringAsync( + "https://gist.githubusercontent.com/MinerPL/731977099ca84bef7ad0a66978010045/raw/stable.headers.json", + innerCancellationToken + ); + + var userHeaders = JsonSerializer.Deserialize>(headersJson); + if (userHeaders is not null) + { + foreach (var kv in userHeaders) + request.Headers.TryAddWithoutValidation(kv.Key, kv.Value); + } + } + catch + { + + } + } + + var response = await Http.Client.SendAsync( request, HttpCompletionOption.ResponseHeadersRead,