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, Snowflake Id,
ChannelKind Kind, ChannelKind Kind,
Snowflake GuildId, Snowflake GuildId,
Snowflake ParentId, Snowflake? ParentId,
string? ParentName, string? ParentName,
int? ParentPosition, int? ParentPosition,
ChannelCategory Category, ChannelCategory Category,
@ -36,7 +36,7 @@ public partial record Channel
json.GetPropertyOrNull("guild_id")?.GetNonWhiteSpaceStringOrNull()?.Pipe(Snowflake.Parse) ?? json.GetPropertyOrNull("guild_id")?.GetNonWhiteSpaceStringOrNull()?.Pipe(Snowflake.Parse) ??
Guild.DirectMessages.Id; 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); var category = categoryHint ?? ChannelCategory.CreateDefault(kind);

View file

@ -10,7 +10,7 @@ public record ChannelThread(
Snowflake Id, Snowflake Id,
ChannelKind Kind, ChannelKind Kind,
Snowflake GuildId, Snowflake GuildId,
Snowflake ParentId, Snowflake? ParentId,
string? ParentName, string? ParentName,
string Name, string Name,
bool IsActive, bool IsActive,
@ -29,7 +29,6 @@ public record ChannelThread(
var parentId = json.GetProperty("parent_id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse); var parentId = json.GetProperty("parent_id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
var name = json.GetProperty("name").GetNonWhiteSpaceString(); var name = json.GetProperty("name").GetNonWhiteSpaceString();
var isActive = !json var isActive = !json
.GetPropertyOrNull("thread_metadata")? .GetPropertyOrNull("thread_metadata")?
.GetPropertyOrNull("archived")? .GetPropertyOrNull("archived")?

View file

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

View file

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