Browse Source

Update DiscordRestApiClient.cs (#357)

Add missing check to Content value to prevent NRE on empty message. 
Also made `ModifyInteractionFollowupMessageAsync`'s check consistent with `CreateInteractionFollowupMessageAsync`
pull/1966/head
exsersewo GitHub 3 years ago
parent
commit
025d16b104
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions
  1. +3
    -5
      src/Discord.Net.Rest/DiscordRestApiClient.cs

+ 3
- 5
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -1353,8 +1353,7 @@ namespace Discord.API
if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && !args.Files.Any())
Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content));


if (args.Content.IsSpecified && args.Content.Value.Length > DiscordConfig.MaxMessageSize)
if (args.Content.IsSpecified && args.Content.Value?.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content));

options = RequestOptions.CreateOrClone(options);
@@ -1368,9 +1367,8 @@ namespace Discord.API
Preconditions.NotNull(args, nameof(args));
Preconditions.NotEqual(id, 0, nameof(id));

if (args.Content.IsSpecified)
if (args.Content.Value.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content));
if (args.Content.IsSpecified && args.Content.Value?.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content));

options = RequestOptions.CreateOrClone(options);



Loading…
Cancel
Save