Allow whitespace in sticker names

This commit is contained in:
Oleksii Holub 2022-05-20 20:45:42 +03:00
parent 17b548d679
commit ca56d47110

View file

@ -4,6 +4,7 @@ using JsonExtensions.Reading;
namespace DiscordChatExporter.Core.Discord.Data; namespace DiscordChatExporter.Core.Discord.Data;
// https://discord.com/developers/docs/resources/sticker#sticker-resource
public record Sticker(Snowflake Id, string Name, StickerFormat Format, string SourceUrl) public record Sticker(Snowflake Id, string Name, StickerFormat Format, string SourceUrl)
{ {
private static string GetSourceUrl(Snowflake id, StickerFormat format) private static string GetSourceUrl(Snowflake id, StickerFormat format)
@ -15,7 +16,7 @@ public record Sticker(Snowflake Id, string Name, StickerFormat Format, string So
public static Sticker Parse(JsonElement json) public static Sticker Parse(JsonElement json)
{ {
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse); var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
var name = json.GetProperty("name").GetNonWhiteSpaceString(); var name = json.GetProperty("name").GetNonNullString();
var format = (StickerFormat)json.GetProperty("format_type").GetInt32(); var format = (StickerFormat)json.GetProperty("format_type").GetInt32();
var sourceUrl = GetSourceUrl(id, format); var sourceUrl = GetSourceUrl(id, format);