Don't use `GetNonWhiteSpaceString()` with nullable JSON fields

Fixes #747
pull/811/head
Tyrrrz 3 years ago
parent ba4ece9325
commit a06b448f4a

@ -45,7 +45,7 @@ public partial record Channel
public static Channel Parse(JsonElement json, ChannelCategory? category = null, int? position = null)
{
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
var guildId = json.GetPropertyOrNull("guild_id")?.GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
var guildId = json.GetPropertyOrNull("guild_id")?.GetStringOrNull()?.Pipe(Snowflake.Parse);
var topic = json.GetPropertyOrNull("topic")?.GetStringOrNull();
var kind = (ChannelKind)json.GetProperty("type").GetInt32();

@ -48,7 +48,7 @@ public partial record Emoji
public static Emoji Parse(JsonElement json)
{
var id = json.GetPropertyOrNull("id")?.GetNonWhiteSpaceString();
var id = json.GetPropertyOrNull("id")?.GetStringOrNull();
var name = json.GetProperty("name").GetNonWhiteSpaceString();
var isAnimated = json.GetPropertyOrNull("animated")?.GetBoolean() ?? false;

Loading…
Cancel
Save