diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml
index a72df4e09..db3bbe3aa 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.xml
+++ b/src/Discord.Net.Core/Discord.Net.Core.xml
@@ -4838,6 +4838,11 @@
The emote of this option.
Render this option as selected by default or not.
+
+
+ Creates a new instance of a from instance of a .
+
+
Sets the field label.
diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
index 89bd6598a..b2423796d 100644
--- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
@@ -906,6 +906,18 @@ namespace Discord
this.Default = @default;
}
+ ///
+ /// Creates a new instance of a from instance of a .
+ ///
+ public SelectMenuOptionBuilder(SelectMenuOption option)
+ {
+ this.Label = option.Label;
+ this.Value = option.Value;
+ this.Description = option.Description;
+ this.Emote = option.Emote;
+ this.Default = option.Default;
+ }
+
///
/// Sets the field label.
///
diff --git a/src/Discord.Net.Core/Utils/Optional.cs b/src/Discord.Net.Core/Utils/Optional.cs
index 348179699..985be9240 100644
--- a/src/Discord.Net.Core/Utils/Optional.cs
+++ b/src/Discord.Net.Core/Utils/Optional.cs
@@ -7,7 +7,7 @@ namespace Discord
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct Optional
{
- public static Optional Unspecified => default(Optional);
+ public static Optional Unspecified => default;
private readonly T _value;
/// Gets the value for this parameter.
@@ -43,18 +43,18 @@ namespace Discord
public override int GetHashCode() => IsSpecified ? _value.GetHashCode() : 0;
public override string ToString() => IsSpecified ? _value?.ToString() : null;
- private string DebuggerDisplay => IsSpecified ? (_value?.ToString() ?? "") : "";
+ private string DebuggerDisplay => IsSpecified ? _value?.ToString() ?? "" : "";
- public static implicit operator Optional(T value) => new Optional(value);
+ public static implicit operator Optional(T value) => new(value);
public static explicit operator T(Optional value) => value.Value;
}
public static class Optional
{
public static Optional Create() => Optional.Unspecified;
- public static Optional Create(T value) => new Optional(value);
+ public static Optional Create(T value) => new(value);
public static T? ToNullable(this Optional val)
where T : struct
- => val.IsSpecified ? val.Value : (T?)null;
+ => val.IsSpecified ? val.Value : null;
}
}
diff --git a/src/Discord.Net.Rest/API/Common/InteractionApplicationCommandCallbackData.cs b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs
similarity index 68%
rename from src/Discord.Net.Rest/API/Common/InteractionApplicationCommandCallbackData.cs
rename to src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs
index 3f7cf93e0..f6e3dcbee 100644
--- a/src/Discord.Net.Rest/API/Common/InteractionApplicationCommandCallbackData.cs
+++ b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs
@@ -1,13 +1,8 @@
using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Discord.API
{
- internal class InteractionApplicationCommandCallbackData
+ internal class InteractionCallbackData
{
[JsonProperty("tts")]
public Optional TTS { get; set; }
@@ -27,12 +22,5 @@ namespace Discord.API
[JsonProperty("components")]
public Optional Components { get; set; }
-
- public InteractionApplicationCommandCallbackData() { }
- public InteractionApplicationCommandCallbackData(string text)
- {
- this.Content = text;
- }
-
}
}
diff --git a/src/Discord.Net.Rest/API/Common/InteractionResponse.cs b/src/Discord.Net.Rest/API/Common/InteractionResponse.cs
index 6be48340b..e50e8076e 100644
--- a/src/Discord.Net.Rest/API/Common/InteractionResponse.cs
+++ b/src/Discord.Net.Rest/API/Common/InteractionResponse.cs
@@ -13,6 +13,6 @@ namespace Discord.API
public InteractionResponseType Type { get; set; }
[JsonProperty("data")]
- public Optional Data { get; set; }
+ public Optional Data { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index 56bfed20e..c24d1ed57 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -55,7 +55,7 @@ namespace Discord.API
_restClientProvider = restClientProvider;
UserAgent = userAgent;
DefaultRetryMode = defaultRetryMode;
- _serializer = serializer ?? new JsonSerializer { ContractResolver = new DiscordContractResolver() };
+ _serializer = serializer ?? new JsonSerializer { ContractResolver = new DiscordContractResolver(), NullValueHandling = NullValueHandling.Ignore };
UseSystemClock = useSystemClock;
RequestQueue = new RequestQueue();
diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
index 89d29ba09..9b285f33f 100644
--- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
+++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
@@ -3452,7 +3452,7 @@
if the message should be read out by a text-to-speech reader, otherwise .
A to send with this response
The type of response to this Interaction.
- /// if the response should be hidden to everyone besides the invoker of the command, otherwise .
+ if the response should be hidden to everyone besides the invoker of the command, otherwise .
The allowed mentions for this response.
The request options for this response.
A to be sent with this response
@@ -3487,7 +3487,7 @@
if the message should be read out by a text-to-speech reader, otherwise .
A array of embeds to send with this response. Max 10
The type of response to this Interaction.
- /// if the response should be hidden to everyone besides the invoker of the command, otherwise .
+ if the response should be hidden to everyone besides the invoker of the command, otherwise .
The allowed mentions for this response.
The request options for this response.
A to be sent with this response
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs
index a89e6de06..8cbfc362e 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs
@@ -107,16 +107,15 @@ namespace Discord.WebSocket
}
- var response = new API.InteractionResponse()
+ var response = new API.InteractionResponse
{
Type = type,
- Data = new API.InteractionApplicationCommandCallbackData(text)
+ Data = new API.InteractionCallbackData
{
+ Content = text ?? Optional.Unspecified,
AllowedMentions = allowedMentions?.ToModel(),
- Embeds = embeds != null
- ? embeds.Select(x => x.ToModel()).ToArray()
- : Optional.Unspecified,
- TTS = isTTS,
+ Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional.Unspecified,
+ TTS = type == InteractionResponseType.ChannelMessageWithSource ? isTTS : Optional.Unspecified,
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified
}
};
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs
index c5f986eed..e3596ec50 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs
@@ -90,16 +90,15 @@ namespace Discord.WebSocket
}
- var response = new API.InteractionResponse()
+ var response = new API.InteractionResponse
{
Type = type,
- Data = new API.InteractionApplicationCommandCallbackData(text)
+ Data = new API.InteractionCallbackData
{
+ Content = text ?? Optional.Unspecified,
AllowedMentions = allowedMentions?.ToModel(),
- Embeds = embeds != null
- ? embeds.Select(x => x.ToModel()).ToArray()
- : Optional.Unspecified,
- TTS = isTTS,
+ Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional.Unspecified,
+ TTS = isTTS ? true : Optional.Unspecified,
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified
}
};
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
index 79a2c81dc..e6a5a9d34 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
@@ -123,7 +123,7 @@ namespace Discord.WebSocket
/// if the message should be read out by a text-to-speech reader, otherwise .
/// A to send with this response
/// The type of response to this Interaction.
- /// /// if the response should be hidden to everyone besides the invoker of the command, otherwise .
+ /// if the response should be hidden to everyone besides the invoker of the command, otherwise .
/// The allowed mentions for this response.
/// The request options for this response.
/// A to be sent with this response
@@ -161,7 +161,7 @@ namespace Discord.WebSocket
/// if the message should be read out by a text-to-speech reader, otherwise .
/// A array of embeds to send with this response. Max 10
/// The type of response to this Interaction.
- /// /// if the response should be hidden to everyone besides the invoker of the command, otherwise .
+ /// if the response should be hidden to everyone besides the invoker of the command, otherwise .
/// The allowed mentions for this response.
/// The request options for this response.
/// A to be sent with this response