Only allow messages with an embed present to be sent with no content
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user