Allow content to be empty when sending a message

This commit is contained in:
Christopher F
2016-11-13 01:02:44 -05:00
parent bad7d827c3
commit 8866a1499c
2 changed files with 6 additions and 4 deletions

View File

@@ -439,8 +439,7 @@ namespace Discord.API
{
Preconditions.NotEqual(channelId, 0, nameof(channelId));
Preconditions.NotNull(args, nameof(args));
Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content));
if (args.Content.Length > DiscordConfig.MaxMessageSize)
if (args.Content.GetValueOrDefault()?.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
options = RequestOptions.CreateOrClone(options);

View File

@@ -8,7 +8,7 @@ namespace Discord.API.Rest
public class CreateMessageParams
{
[JsonProperty("content")]
public string Content { get; }
public Optional<string> Content { get; }
[JsonProperty("nonce")]
public Optional<string> Nonce { get; set; }
@@ -19,7 +19,10 @@ namespace Discord.API.Rest
public CreateMessageParams(string content)
{
Content = content;
if (string.IsNullOrEmpty(content))
Content = null;
else
Content = content;
}
}
}