Browse Source

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

tags/1.0-rc
Christopher F 8 years ago
parent
commit
3698dbfedc
2 changed files with 7 additions and 6 deletions
  1. +4
    -1
      src/Discord.Net.Core/API/DiscordRestApiClient.cs
  2. +3
    -5
      src/Discord.Net.Core/API/Rest/CreateMessageParams.cs

+ 4
- 1
src/Discord.Net.Core/API/DiscordRestApiClient.cs 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);



+ 3
- 5
src/Discord.Net.Core/API/Rest/CreateMessageParams.cs 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;
}
}
}

Loading…
Cancel
Save