From 0de1f47310b09ac08abf09dc1a09799c7c95e783 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sun, 9 Jan 2022 22:24:02 +0200 Subject: [PATCH] More parsing leniency Closes #767 --- DiscordChatExporter.Core/Discord/Data/Attachment.cs | 2 +- DiscordChatExporter.Core/Discord/Data/Guild.cs | 2 +- DiscordChatExporter.Core/Discord/Data/Role.cs | 2 +- DiscordChatExporter.Core/Discord/Data/User.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DiscordChatExporter.Core/Discord/Data/Attachment.cs b/DiscordChatExporter.Core/Discord/Data/Attachment.cs index f8ca229..6776670 100644 --- a/DiscordChatExporter.Core/Discord/Data/Attachment.cs +++ b/DiscordChatExporter.Core/Discord/Data/Attachment.cs @@ -36,7 +36,7 @@ public partial record Attachment var url = json.GetProperty("url").GetNonWhiteSpaceString(); var width = json.GetPropertyOrNull("width")?.GetInt32OrNull(); var height = json.GetPropertyOrNull("height")?.GetInt32OrNull(); - var fileName = json.GetProperty("filename").GetNonWhiteSpaceString(); + var fileName = json.GetProperty("filename").GetNonNullString(); var fileSize = json.GetProperty("size").GetInt64().Pipe(FileSize.FromBytes); return new Attachment(id, url, fileName, width, height, fileSize); diff --git a/DiscordChatExporter.Core/Discord/Data/Guild.cs b/DiscordChatExporter.Core/Discord/Data/Guild.cs index aca97c7..b83ab53 100644 --- a/DiscordChatExporter.Core/Discord/Data/Guild.cs +++ b/DiscordChatExporter.Core/Discord/Data/Guild.cs @@ -23,7 +23,7 @@ public record Guild(Snowflake Id, string Name, string IconUrl) : IHasId public static Guild Parse(JsonElement json) { var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse); - var name = json.GetProperty("name").GetNonWhiteSpaceString(); + var name = json.GetProperty("name").GetNonNullString(); var iconHash = json.GetPropertyOrNull("icon")?.GetNonWhiteSpaceStringOrNull(); var iconUrl = !string.IsNullOrWhiteSpace(iconHash) diff --git a/DiscordChatExporter.Core/Discord/Data/Role.cs b/DiscordChatExporter.Core/Discord/Data/Role.cs index b29b1db..c9dca21 100644 --- a/DiscordChatExporter.Core/Discord/Data/Role.cs +++ b/DiscordChatExporter.Core/Discord/Data/Role.cs @@ -12,7 +12,7 @@ public record Role(Snowflake Id, string Name, int Position, Color? Color) : IHas public static Role Parse(JsonElement json) { var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse); - var name = json.GetProperty("name").GetNonWhiteSpaceString(); + var name = json.GetProperty("name").GetNonNullString(); var position = json.GetProperty("position").GetInt32(); var color = json diff --git a/DiscordChatExporter.Core/Discord/Data/User.cs b/DiscordChatExporter.Core/Discord/Data/User.cs index a967523..968fae5 100644 --- a/DiscordChatExporter.Core/Discord/Data/User.cs +++ b/DiscordChatExporter.Core/Discord/Data/User.cs @@ -38,7 +38,7 @@ public partial record User var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse); var isBot = json.GetPropertyOrNull("bot")?.GetBooleanOrNull() ?? false; var discriminator = json.GetProperty("discriminator").GetNonWhiteSpaceString().Pipe(int.Parse); - var name = json.GetProperty("username").GetNonWhiteSpaceString(); + var name = json.GetProperty("username").GetNonNullString(); var avatarHash = json.GetPropertyOrNull("avatar")?.GetNonWhiteSpaceStringOrNull(); var avatarUrl = !string.IsNullOrWhiteSpace(avatarHash)