From 8e4d4496152b7e142dd69b6cb68bf34c616cd535 Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:38:46 +0300 Subject: [PATCH] Remove checks from `UpdateAsync` methods (#2790) --- .../MessageComponents/RestMessageComponent.cs | 6 ------ .../Entities/Interactions/Modals/RestModal.cs | 6 ------ .../MessageComponents/SocketMessageComponent.cs | 10 ---------- .../Entities/Interaction/Modals/SocketModal.cs | 6 ------ 4 files changed, 28 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs index a59767c0..360fd2b4 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs @@ -162,12 +162,6 @@ namespace Discord.Rest var embed = args.Embed; var embeds = args.Embeds; - bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : !string.IsNullOrEmpty(Message.Content); - bool hasEmbeds = embed.IsSpecified && embed.Value != null || embeds.IsSpecified && embeds.Value?.Length > 0 || Message.Embeds.Any(); - - if (!hasText && !hasEmbeds) - Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content)); - var apiEmbeds = embed.IsSpecified || embeds.IsSpecified ? new List() : null; if (embed.IsSpecified && embed.Value != null) diff --git a/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs b/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs index 33220d88..3e7a0266 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/Modals/RestModal.cs @@ -475,12 +475,6 @@ namespace Discord.Rest var embed = args.Embed; var embeds = args.Embeds; - bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : false; - bool hasEmbeds = embed.IsSpecified && embed.Value != null || embeds.IsSpecified && embeds.Value?.Length > 0; - - if (!hasText && !hasEmbeds) - Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content)); - var apiEmbeds = embed.IsSpecified || embeds.IsSpecified ? new List() : null; if (embed.IsSpecified && embed.Value != null) diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs index 6691bc6e..23c6f144 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs @@ -224,16 +224,6 @@ namespace Discord.WebSocket var embed = args.Embed; var embeds = args.Embeds; - bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : !string.IsNullOrEmpty(Message.Content); - bool hasEmbeds = embed.IsSpecified && embed.Value != null || embeds.IsSpecified && embeds.Value?.Length > 0 || Message.Embeds.Any(); - bool hasComponents = args.Components.IsSpecified && args.Components.Value != null; - bool hasAttachments = args.Attachments.IsSpecified; - bool hasFlags = args.Flags.IsSpecified; - - // No content needed if modifying flags - if ((!hasComponents && !hasText && !hasEmbeds && !hasAttachments) && !hasFlags) - Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content)); - var apiEmbeds = embed.IsSpecified || embeds.IsSpecified ? new List() : null; if (embed.IsSpecified && embed.Value != null) diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs index ff1d4dc8..9c2f25e7 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModal.cs @@ -221,12 +221,6 @@ namespace Discord.WebSocket var embed = args.Embed; var embeds = args.Embeds; - bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : false; - bool hasEmbeds = embed.IsSpecified && embed.Value != null || embeds.IsSpecified && embeds.Value?.Length > 0; - - if (!hasText && !hasEmbeds) - Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content)); - var apiEmbeds = embed.IsSpecified || embeds.IsSpecified ? new List() : null; if (embed.IsSpecified && embed.Value != null)