diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index afa4af9e6..09f5a5767 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -494,13 +494,8 @@ namespace Discord.API if (args.Content.GetValueOrDefault(null) == null) args.Content = ""; - else if (args.Content.IsSpecified) - { - if (args.Content.Value == null) - args.Content = ""; - if (args.Content.Value?.Length > DiscordConfig.MaxMessageSize) - throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content)); - } + else if (args.Content.IsSpecified && args.Content.Value?.Length > DiscordConfig.MaxMessageSize) + throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content)); var ids = new BucketIds(channelId: channelId); return await SendMultipartAsync("POST", () => $"channels/{channelId}/messages", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Net/DefaultRestClient.cs b/src/Discord.Net.Rest/Net/DefaultRestClient.cs index 39b94294f..2381a9976 100644 --- a/src/Discord.Net.Rest/Net/DefaultRestClient.cs +++ b/src/Discord.Net.Rest/Net/DefaultRestClient.cs @@ -101,7 +101,14 @@ namespace Discord.Net.Rest if (p.Value is MultipartFile) { var fileValue = (MultipartFile)p.Value; - content.Add(new StreamContent(fileValue.Stream), p.Key, fileValue.Filename); + var stream = fileValue.Stream; + if (!stream.CanSeek) + { + var memoryStream = new MemoryStream(); + await stream.CopyToAsync(memoryStream).ConfigureAwait(false); + stream = memoryStream; + } + content.Add(new StreamContent(stream), p.Key, fileValue.Filename); continue; }