Browse Source

Add missing checks

pull/2336/head
d4n3436 3 years ago
parent
commit
cdfaa946d2
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs

+ 5
- 1
src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs View File

@@ -226,8 +226,12 @@ namespace Discord.WebSocket


bool hasText = args.Content.IsSpecified ? !string.IsNullOrEmpty(args.Content.Value) : !string.IsNullOrEmpty(Message.Content); 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 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;


if (!hasText && !hasEmbeds)
// 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)); Preconditions.NotNullOrEmpty(args.Content.IsSpecified ? args.Content.Value : string.Empty, nameof(args.Content));


var apiEmbeds = embed.IsSpecified || embeds.IsSpecified ? new List<API.Embed>() : null; var apiEmbeds = embed.IsSpecified || embeds.IsSpecified ? new List<API.Embed>() : null;


Loading…
Cancel
Save