Expect channel parents to be null

This commit is contained in:
Tyrrrz 2023-07-08 19:21:00 +03:00
parent 8776a6955b
commit 51192425b7
4 changed files with 6 additions and 7 deletions

View file

@ -11,7 +11,7 @@ public partial record Channel(
Snowflake Id,
ChannelKind Kind,
Snowflake GuildId,
Snowflake ParentId,
Snowflake? ParentId,
string? ParentName,
int? ParentPosition,
ChannelCategory Category,
@ -36,7 +36,7 @@ public partial record Channel
json.GetPropertyOrNull("guild_id")?.GetNonWhiteSpaceStringOrNull()?.Pipe(Snowflake.Parse) ??
Guild.DirectMessages.Id;
var parentId = json.GetProperty("parent_id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
var parentId = json.GetPropertyOrNull("parent_id")?.GetNonWhiteSpaceStringOrNull()?.Pipe(Snowflake.Parse);
var category = categoryHint ?? ChannelCategory.CreateDefault(kind);

View file

@ -10,7 +10,7 @@ public record ChannelThread(
Snowflake Id,
ChannelKind Kind,
Snowflake GuildId,
Snowflake ParentId,
Snowflake? ParentId,
string? ParentName,
string Name,
bool IsActive,
@ -29,7 +29,6 @@ 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")?

View file

@ -4,7 +4,7 @@ public interface IChannel : IHasId
{
ChannelKind Kind { get; }
Snowflake GuildId { get; }
Snowflake ParentId { get; }
Snowflake? ParentId { get; }
string? ParentName { get; }
int? ParentPosition { get; }
string Name { get; }
@ -12,4 +12,4 @@ public interface IChannel : IHasId
string? IconUrl { get; }
string? Topic { get; }
Snowflake? LastMessageId { get; }
}
}

View file

@ -149,7 +149,7 @@ public partial class ExportRequest
{
"%g" => guild.Id.ToString(),
"%G" => guild.Name,
"%t" => channel.ParentId.ToString(),
"%t" => channel.ParentId.ToString() ?? "",
"%T" => channel.ParentName ?? "",
"%c" => channel.Id.ToString(),
"%C" => channel.Name,