| @@ -13,7 +13,7 @@ namespace Discord.API.Rest | |||||
| private static JsonSerializer _serializer = new JsonSerializer { ContractResolver = new DiscordContractResolver() }; | private static JsonSerializer _serializer = new JsonSerializer { ContractResolver = new DiscordContractResolver() }; | ||||
| [JsonProperty("content")] | [JsonProperty("content")] | ||||
| public string Content { get; set; } | |||||
| public Optional<string> Content { get; set; } | |||||
| [JsonProperty("nonce")] | [JsonProperty("nonce")] | ||||
| public Optional<string> Nonce { get; set; } | public Optional<string> Nonce { get; set; } | ||||
| @@ -786,8 +786,9 @@ namespace Discord.API | |||||
| if (!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) | if (!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) | ||||
| Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); | Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); | ||||
| if (args.Content?.Length > DiscordConfig.MaxMessageSize) | |||||
| if (args.Content.IsSpecified && args.Content.Value?.Length > DiscordConfig.MaxMessageSize) | |||||
| throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); | throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| var ids = new BucketIds(webhookId: webhookId); | var ids = new BucketIds(webhookId: webhookId); | ||||
| @@ -1336,7 +1337,7 @@ namespace Discord.API | |||||
| if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && !args.File.IsSpecified) | if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && !args.File.IsSpecified) | ||||
| Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); | Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); | ||||
| if (args.Content?.Length > DiscordConfig.MaxMessageSize) | |||||
| if(args.Content.IsSpecified && args.Content.Value?.Length > DiscordConfig.MaxMessageSize) | |||||
| throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); | throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| @@ -115,7 +115,7 @@ namespace Discord.Rest | |||||
| Type = InteractionResponseType.ChannelMessageWithSource, | Type = InteractionResponseType.ChannelMessageWithSource, | ||||
| Data = new API.InteractionCallbackData | Data = new API.InteractionCallbackData | ||||
| { | { | ||||
| Content = text, | |||||
| Content = text ?? Optional<string>.Unspecified, | |||||
| AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | ||||
| Embeds = embeds.Select(x => x.ToModel()).ToArray(), | Embeds = embeds.Select(x => x.ToModel()).ToArray(), | ||||
| TTS = isTTS, | TTS = isTTS, | ||||
| @@ -114,7 +114,7 @@ namespace Discord.WebSocket | |||||
| Type = InteractionResponseType.ChannelMessageWithSource, | Type = InteractionResponseType.ChannelMessageWithSource, | ||||
| Data = new API.InteractionCallbackData | Data = new API.InteractionCallbackData | ||||
| { | { | ||||
| Content = text, | |||||
| Content = text ?? Optional<string>.Unspecified, | |||||
| AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | ||||
| Embeds = embeds.Select(x => x.ToModel()).ToArray(), | Embeds = embeds.Select(x => x.ToModel()).ToArray(), | ||||
| TTS = isTTS, | TTS = isTTS, | ||||
| @@ -168,7 +168,7 @@ namespace Discord.WebSocket | |||||
| var args = new API.Rest.CreateWebhookMessageParams | var args = new API.Rest.CreateWebhookMessageParams | ||||
| { | { | ||||
| Content = text, | |||||
| Content = text ?? Optional<string>.Unspecified, | |||||
| AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | ||||
| IsTTS = isTTS, | IsTTS = isTTS, | ||||
| Embeds = embeds.Select(x => x.ToModel()).ToArray(), | Embeds = embeds.Select(x => x.ToModel()).ToArray(), | ||||