Only allow messages with an embed present to be sent with no content

This commit is contained in:
Christopher F
2016-11-13 14:16:49 -05:00
parent 754970bb56
commit 3698dbfedc
2 changed files with 7 additions and 6 deletions

View File

@@ -439,7 +439,10 @@ namespace Discord.API
{
Preconditions.NotEqual(channelId, 0, nameof(channelId));
Preconditions.NotNull(args, nameof(args));
if (args.Content.GetValueOrDefault()?.Length > DiscordConfig.MaxMessageSize)
if (!args.Embed.IsSpecified || args.Embed.Value == null)
Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content));
if (args.Content.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,8 @@ namespace Discord.API.Rest
public class CreateMessageParams
{
[JsonProperty("content")]
public Optional<string> Content { get; }
public string Content { get; }
[JsonProperty("nonce")]
public Optional<string> Nonce { get; set; }
[JsonProperty("tts")]
@@ -18,10 +19,7 @@ namespace Discord.API.Rest
public CreateMessageParams(string content)
{
if (string.IsNullOrEmpty(content))
Content = Optional.Create<string>();
else
Content = content;
Content = content;
}
}
}