From dbc13d58b6db0b58cece228c0e63dc3811523b8d Mon Sep 17 00:00:00 2001 From: quin lynch Date: Fri, 28 May 2021 07:48:50 -0300 Subject: [PATCH] Fix null ref for emotes --- .../API/Common/ButtonComponent.cs | 10 +++++----- src/Discord.Net.Rest/Discord.Net.Rest.csproj | 2 +- .../Entities/Messages/RestMessage.cs | 10 +++++----- .../Entities/Messages/SocketMessage.cs | 12 +++++------ src/Discord.Net/Discord.Net.nuspec | 20 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/ButtonComponent.cs b/src/Discord.Net.Rest/API/Common/ButtonComponent.cs index dd10bcd44..775f78101 100644 --- a/src/Discord.Net.Rest/API/Common/ButtonComponent.cs +++ b/src/Discord.Net.Rest/API/Common/ButtonComponent.cs @@ -16,19 +16,19 @@ namespace Discord.API public ButtonStyle Style { get; set; } [JsonProperty("label")] - public string Label { get; set; } + public Optional Label { get; set; } [JsonProperty("emoji")] - public Emoji Emote { get; set; } + public Optional Emote { get; set; } [JsonProperty("custom_id")] - public string CustomId { get; set; } + public Optional CustomId { get; set; } [JsonProperty("url")] - public string Url { get; set; } + public Optional Url { get; set; } [JsonProperty("disabled")] - public bool Disabled { get; set; } + public Optional Disabled { get; set; } public ButtonComponent() { } diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.csproj b/src/Discord.Net.Rest/Discord.Net.Rest.csproj index 562cb2d74..770ef3bdc 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.csproj +++ b/src/Discord.Net.Rest/Discord.Net.Rest.csproj @@ -9,7 +9,7 @@ netstandard2.0;netstandard2.1 Temporary.png https://github.com/Discord-Net-Labs/Discord.Net-Labs - 2.3.3 + 2.3.4 Discord.Net.Labs.Rest https://github.com/Discord-Net-Labs/Discord.Net-Labs diff --git a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs index 1a568992b..90bdc8636 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs @@ -132,11 +132,11 @@ namespace Discord.Rest Components = model.Components.Value.Select(x => new ActionRowComponent(x.Components.Select(x => new ButtonComponent( x.Style, - x.Label, - x.Emote.Id.HasValue ? new Emote(x.Emote.Id.Value, x.Emote.Name, x.Emote.Animated.GetValueOrDefault()) : new Emoji(x.Emote.Name), - x.CustomId, - x.Url, - x.Disabled) + x.Label.GetValueOrDefault(), + x.Emote.IsSpecified ? x.Emote.Value.Id.HasValue ? new Emote(x.Emote.Value.Id.Value, x.Emote.Value.Name, x.Emote.Value.Animated.GetValueOrDefault()) : new Emoji(x.Emote.Value.Name) : null, + x.CustomId.GetValueOrDefault(), + x.Url.GetValueOrDefault(), + x.Disabled.GetValueOrDefault()) ).ToList() )).ToList(); } diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs index e6052c179..e201d3e97 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs @@ -163,13 +163,13 @@ namespace Discord.WebSocket if (model.Components.IsSpecified) { Components = model.Components.Value.Select(x => new ActionRowComponent(x.Components.Select(x => - new ButtonComponent( + new ButtonComponent( x.Style, - x.Label, - x.Emote.Id.HasValue ? new Emote(x.Emote.Id.Value, x.Emote.Name, x.Emote.Animated.GetValueOrDefault()) : new Emoji(x.Emote.Name), - x.CustomId, - x.Url, - x.Disabled) + x.Label.GetValueOrDefault(), + x.Emote.IsSpecified ? x.Emote.Value.Id.HasValue ? new Emote(x.Emote.Value.Id.Value, x.Emote.Value.Name, x.Emote.Value.Animated.GetValueOrDefault()) : new Emoji(x.Emote.Value.Name) : null, + x.CustomId.GetValueOrDefault(), + x.Url.GetValueOrDefault(), + x.Disabled.GetValueOrDefault()) ).ToList() )).ToList(); } diff --git a/src/Discord.Net/Discord.Net.nuspec b/src/Discord.Net/Discord.Net.nuspec index 2c2e7b56b..8694a1ff7 100644 --- a/src/Discord.Net/Discord.Net.nuspec +++ b/src/Discord.Net/Discord.Net.nuspec @@ -2,7 +2,7 @@ Discord.Net.Labs - 2.3.1$suffix$ + 2.3.2$suffix$ Discord.Net Labs Discord.Net Contributors quinchs @@ -14,23 +14,23 @@ https://avatars.githubusercontent.com/u/84047264 - - - + + + - - - + + + - - - + + +