From 675d910ea3ff92fe5700a0b8a9e980c5cbf0647f Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:56:29 +0200 Subject: [PATCH] Formatting --- .../Infra/ChannelIds.cs | 4 +-- .../Specs/HtmlForwardSpecs.cs | 5 +--- .../Specs/JsonForwardSpecs.cs | 1 - .../Specs/PlainTextForwardSpecs.cs | 4 +-- .../Discord/Data/Message.cs | 2 +- .../Discord/Data/MessageReference.cs | 5 ++-- .../Discord/Data/MessageSnapshot.cs | 29 +++++++++---------- .../Exporting/JsonMessageWriter.cs | 6 ++-- .../Exporting/PlainTextMessageWriter.cs | 6 ++-- .../Utils/Extensions/CollectionExtensions.cs | 2 +- 10 files changed, 29 insertions(+), 35 deletions(-) diff --git a/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs b/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs index e380e136..81ab8791 100644 --- a/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs +++ b/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs @@ -1,4 +1,4 @@ -using DiscordChatExporter.Core.Discord; +using DiscordChatExporter.Core.Discord; namespace DiscordChatExporter.Cli.Tests.Infra; @@ -15,7 +15,7 @@ public static class ChannelIds public static Snowflake GroupingTestCases { get; } = Snowflake.Parse("992092091545034842"); public static Snowflake FilterTestCases { get; } = Snowflake.Parse("866744075033641020"); - + public static Snowflake ForwardTestCases { get; } = Snowflake.Parse("1455202357204877477"); public static Snowflake MarkdownTestCases { get; } = Snowflake.Parse("866459526819348521"); diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs index 1322008c..c3dbfe5f 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs @@ -19,9 +19,6 @@ public class HtmlForwardSpecs ); // Assert - message - .Text() - .Should() - .ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025"); + message.Text().Should().ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025"); } } diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs index ca2ddd4e..5e1237bf 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs @@ -27,4 +27,3 @@ public class JsonForwardSpecs forwardedMessage.GetProperty("timestamp").GetString().Should().StartWith("2025-12-29"); } } - diff --git a/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs index 7d543a8d..2461af88 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs @@ -14,8 +14,6 @@ public class PlainTextForwardSpecs var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.ForwardTestCases); // Assert - document - .Should() - .ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025"); + document.Should().ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025"); } } diff --git a/DiscordChatExporter.Core/Discord/Data/Message.cs b/DiscordChatExporter.Core/Discord/Data/Message.cs index ad568695..9b1c4f92 100644 --- a/DiscordChatExporter.Core/Discord/Data/Message.cs +++ b/DiscordChatExporter.Core/Discord/Data/Message.cs @@ -180,7 +180,7 @@ public partial record Message // Currently Discord only supports 1 snapshot per forward var forwardedMessage = json.GetPropertyOrNull("message_snapshots") ?.EnumerateArrayOrNull() - ?.Select(j => j.GetPropertyOrNull("message")) + ?.Select(j => j.GetPropertyOrNull("message")) .WhereNotNull() .Select(MessageSnapshot.Parse) .FirstOrDefault(); diff --git a/DiscordChatExporter.Core/Discord/Data/MessageReference.cs b/DiscordChatExporter.Core/Discord/Data/MessageReference.cs index 73374d6a..48c68d5f 100644 --- a/DiscordChatExporter.Core/Discord/Data/MessageReference.cs +++ b/DiscordChatExporter.Core/Discord/Data/MessageReference.cs @@ -9,14 +9,15 @@ public record MessageReference( MessageReferenceKind Kind, Snowflake? MessageId, Snowflake? ChannelId, - Snowflake? GuildId) + Snowflake? GuildId +) { public static MessageReference Parse(JsonElement json) { var kind = json.GetPropertyOrNull("type")?.GetInt32OrNull()?.Pipe(t => (MessageReferenceKind)t) ?? MessageReferenceKind.Default; - + var messageId = json.GetPropertyOrNull("message_id") ?.GetNonWhiteSpaceStringOrNull() ?.Pipe(Snowflake.Parse); diff --git a/DiscordChatExporter.Core/Discord/Data/MessageSnapshot.cs b/DiscordChatExporter.Core/Discord/Data/MessageSnapshot.cs index db0d1722..212502b4 100644 --- a/DiscordChatExporter.Core/Discord/Data/MessageSnapshot.cs +++ b/DiscordChatExporter.Core/Discord/Data/MessageSnapshot.cs @@ -15,7 +15,8 @@ public record MessageSnapshot( string Content, IReadOnlyList Attachments, IReadOnlyList Embeds, - IReadOnlyList Stickers) + IReadOnlyList Stickers +) { public static MessageSnapshot Parse(JsonElement json) { @@ -23,37 +24,35 @@ public record MessageSnapshot( json.GetPropertyOrNull("timestamp")?.GetDateTimeOffsetOrNull() ?? DateTimeOffset.MinValue; - var editedTimestamp = json - .GetPropertyOrNull("edited_timestamp") - ?.GetDateTimeOffsetOrNull(); + var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffsetOrNull(); var content = json.GetPropertyOrNull("content")?.GetStringOrNull() ?? ""; var attachments = - json - .GetPropertyOrNull("attachments") + json.GetPropertyOrNull("attachments") ?.EnumerateArrayOrNull() ?.Select(Attachment.Parse) .ToArray() ?? []; var embeds = - json - .GetPropertyOrNull("embeds") - ?.EnumerateArrayOrNull() - ?.Select(Embed.Parse) - .ToArray() + json.GetPropertyOrNull("embeds")?.EnumerateArrayOrNull()?.Select(Embed.Parse).ToArray() ?? []; var stickers = - json - .GetPropertyOrNull("sticker_items") + json.GetPropertyOrNull("sticker_items") ?.EnumerateArrayOrNull() ?.Select(Sticker.Parse) .ToArray() ?? []; - return new MessageSnapshot(timestamp, - editedTimestamp, content, attachments, embeds, stickers); + return new MessageSnapshot( + timestamp, + editedTimestamp, + content, + attachments, + embeds, + stickers + ); } } diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index c7c2039f..6bb8cc11 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -352,7 +352,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) _writer.WriteEndObject(); await _writer.FlushAsync(cancellationToken); } - + private async ValueTask WriteStickerAsync( Sticker sticker, CancellationToken cancellationToken = default @@ -553,14 +553,14 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) _writer.WriteString( "timestamp", - Context.NormalizeDate(message.ForwardedMessage.Timestamp) + Context.NormalizeDate(message.ForwardedMessage.Timestamp) ); _writer.WriteString( "timestampEdited", message.ForwardedMessage.EditedTimestamp?.Pipe(Context.NormalizeDate) ); - + _writer.WriteString( "content", await FormatMarkdownAsync(message.ForwardedMessage.Content, cancellationToken) diff --git a/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs b/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs index 6ddfcc1d..7bd6e438 100644 --- a/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs @@ -239,9 +239,9 @@ internal class PlainTextMessageWriter(Stream stream, ExportContext context) ); } - await _writer.WriteLineAsync( - $"Originally sent: {Context.FormatDate(forwardedMessage.Timestamp)}" - ); + await _writer.WriteLineAsync( + $"Originally sent: {Context.FormatDate(forwardedMessage.Timestamp)}" + ); await WriteAttachmentsAsync(forwardedMessage.Attachments, cancellationToken); await WriteEmbedsAsync(forwardedMessage.Embeds, cancellationToken); diff --git a/DiscordChatExporter.Core/Utils/Extensions/CollectionExtensions.cs b/DiscordChatExporter.Core/Utils/Extensions/CollectionExtensions.cs index 72a8f249..abb1dd9a 100644 --- a/DiscordChatExporter.Core/Utils/Extensions/CollectionExtensions.cs +++ b/DiscordChatExporter.Core/Utils/Extensions/CollectionExtensions.cs @@ -24,7 +24,7 @@ public static class CollectionExtensions } } } - + extension(IEnumerable source) where T : struct {