Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Update DiscordRestApiClient.cs #357

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Discord.Net.Rest/DiscordRestApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,7 @@ public async Task<Message> CreateInteractionFollowupMessageAsync(UploadWebhookFi
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);
Expand All @@ -1368,9 +1367,8 @@ public async Task<Message> ModifyInteractionFollowupMessageAsync(ModifyInteracti
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);

Expand Down