Skip to content

Commit

Permalink
Fixes Role creation deserialization failure
Browse files Browse the repository at this point in the history
  • Loading branch information
gehongyan committed Mar 18, 2023
1 parent 2b5c59d commit 1726d5c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Kook.Net.Rest/API/Common/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class Role
public Color Color { get; set; }

[JsonPropertyName("color_type")]
public ColorType ColorType { get; set; }
public ColorType? ColorType { get; set; }

[JsonPropertyName("color_map")]
[JsonConverter(typeof(NullableGradientColorConverter))]
Expand Down
2 changes: 1 addition & 1 deletion src/Kook.Net.Rest/Entities/Roles/RestRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal void Update(Model model)
Name = model.Name;
Type = model.Type;
Color = model.Color;
ColorType = model.ColorType;
ColorType = model.ColorType ?? ColorType.Solid; // BUG: The API returns null when creating new roles.
GradientColor = model.GradientColor;
IsHoisted = model.Hoist == 1;
IsMentionable = model.Mentionable == 1;
Expand Down
2 changes: 1 addition & 1 deletion src/Kook.Net.Rest/Kook.Net.Rest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>TRACE_REST;DEBUG_REST</DefineConstants>
<DefineConstants>TRACE_REST</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Kook.Net.WebSocket/Entities/Roles/SocketRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal void Update(ClientState state, Model model)
Name = model.Name;
Type = model.Type;
Color = model.Color;
ColorType = model.ColorType;
ColorType = model.ColorType ?? ColorType.Solid; // BUG: The API returns null when creating new roles.
GradientColor = model.GradientColor;
Position = model.Position;
IsHoisted = model.Hoist switch
Expand Down

0 comments on commit 1726d5c

Please sign in to comment.