Allow content to be empty when sending a message
This commit is contained in:
@@ -439,8 +439,7 @@ namespace Discord.API
|
|||||||
{
|
{
|
||||||
Preconditions.NotEqual(channelId, 0, nameof(channelId));
|
Preconditions.NotEqual(channelId, 0, nameof(channelId));
|
||||||
Preconditions.NotNull(args, nameof(args));
|
Preconditions.NotNull(args, nameof(args));
|
||||||
Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content));
|
if (args.Content.GetValueOrDefault()?.Length > DiscordConfig.MaxMessageSize)
|
||||||
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));
|
throw new ArgumentException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
|
||||||
options = RequestOptions.CreateOrClone(options);
|
options = RequestOptions.CreateOrClone(options);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Discord.API.Rest
|
|||||||
public class CreateMessageParams
|
public class CreateMessageParams
|
||||||
{
|
{
|
||||||
[JsonProperty("content")]
|
[JsonProperty("content")]
|
||||||
public string Content { get; }
|
public Optional<string> Content { get; }
|
||||||
|
|
||||||
[JsonProperty("nonce")]
|
[JsonProperty("nonce")]
|
||||||
public Optional<string> Nonce { get; set; }
|
public Optional<string> Nonce { get; set; }
|
||||||
@@ -19,7 +19,10 @@ namespace Discord.API.Rest
|
|||||||
|
|
||||||
public CreateMessageParams(string content)
|
public CreateMessageParams(string content)
|
||||||
{
|
{
|
||||||
Content = content;
|
if (string.IsNullOrEmpty(content))
|
||||||
|
Content = null;
|
||||||
|
else
|
||||||
|
Content = content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user