Extract thread status and improve CLI output

This commit is contained in:
Tyrrrz
2023-06-09 01:20:32 +03:00
parent 609ca0fc0d
commit 11d34109a7
4 changed files with 46 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ public record ChannelThread(
Snowflake GuildId,
Snowflake ParentId,
string Name,
bool IsActive,
Snowflake? LastMessageId) : IHasId
{
public static ChannelThread Parse(JsonElement json)
@@ -22,6 +23,11 @@ public record ChannelThread(
var parentId = json.GetProperty("parent_id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
var name = json.GetProperty("name").GetNonWhiteSpaceString();
var isActive = !json
.GetPropertyOrNull("thread_metadata")?
.GetPropertyOrNull("archived")?
.GetBooleanOrNull() ?? true;
var lastMessageId = json
.GetPropertyOrNull("last_message_id")?
.GetNonWhiteSpaceStringOrNull()?
@@ -33,6 +39,7 @@ public record ChannelThread(
guildId,
parentId,
name,
isActive,
lastMessageId
);
}