Browse Source

Merge branch 'release/3.x' into dnet-staging

pull/1958/head
quin lynch 3 years ago
parent
commit
44fc1fd3e4
4 changed files with 7 additions and 6 deletions
  1. +1
    -1
      src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs
  2. +3
    -2
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  3. +1
    -1
      src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestCommandBase.cs
  4. +2
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs

+ 1
- 1
src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs View File

@@ -13,7 +13,7 @@ namespace Discord.API.Rest
private static JsonSerializer _serializer = new JsonSerializer { ContractResolver = new DiscordContractResolver() };

[JsonProperty("content")]
public string Content { get; set; }
public Optional<string> Content { get; set; }

[JsonProperty("nonce")]
public Optional<string> Nonce { get; set; }


+ 3
- 2
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -786,8 +786,9 @@ namespace Discord.API
if (!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0)
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));

options = RequestOptions.CreateOrClone(options);

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)
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));

options = RequestOptions.CreateOrClone(options);


+ 1
- 1
src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestCommandBase.cs View File

@@ -115,7 +115,7 @@ namespace Discord.Rest
Type = InteractionResponseType.ChannelMessageWithSource,
Data = new API.InteractionCallbackData
{
Content = text,
Content = text ?? Optional<string>.Unspecified,
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
TTS = isTTS,


+ 2
- 2
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs View File

@@ -114,7 +114,7 @@ namespace Discord.WebSocket
Type = InteractionResponseType.ChannelMessageWithSource,
Data = new API.InteractionCallbackData
{
Content = text,
Content = text ?? Optional<string>.Unspecified,
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
Embeds = embeds.Select(x => x.ToModel()).ToArray(),
TTS = isTTS,
@@ -168,7 +168,7 @@ namespace Discord.WebSocket

var args = new API.Rest.CreateWebhookMessageParams
{
Content = text,
Content = text ?? Optional<string>.Unspecified,
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
IsTTS = isTTS,
Embeds = embeds.Select(x => x.ToModel()).ToArray(),


Loading…
Cancel
Save