diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj
index 8ff32d2bb..da9636eac 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.csproj
+++ b/src/Discord.Net.Core/Discord.Net.Core.csproj
@@ -8,7 +8,7 @@
net461;netstandard2.0;netstandard2.1netstandard2.0;netstandard2.1Discord.Net.Labs.Core
- 2.3.9-dev
+ 2.4.0Discord.Net.Labs.Corehttps://github.com/Discord-Net-Labs/Discord.Net-LabsTemporary.png
diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml
index 469250410..e33891477 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.xml
+++ b/src/Discord.Net.Core/Discord.Net.Core.xml
@@ -5023,30 +5023,30 @@
Adds a choice to the current option.
- The name of the choice.
- The value of the choice.
+ The name of the choice.
+ The value of the choice.
The current builder.
Adds a choice to the current option.
- The name of the choice.
- The value of the choice.
+ The name of the choice.
+ The value of the choice.
The current builder.
Sets the current builders name.
- The name to set the current option builder.
+ The name to set the current option builder.
The current builder.
Sets the current builders description.
- The description to set.
+ The description to set.
The current builder.
@@ -5067,7 +5067,7 @@
Sets the current type of this builder.
- The type to set.
+ The type to set.
The current builder.
diff --git a/src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataOption.cs b/src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataOption.cs
index 33d04800f..0eea07b83 100644
--- a/src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataOption.cs
+++ b/src/Discord.Net.Rest/API/Common/ApplicationCommandInteractionDataOption.cs
@@ -8,6 +8,9 @@ namespace Discord.API
[JsonProperty("name")]
public string Name { get; set; }
+ [JsonProperty("type")]
+ public ApplicationCommandOptionType Type { get; set; }
+
[JsonProperty("value")]
public Optional
+
+
+ if the token is valid for replying to, otherwise .
@@ -3393,7 +3396,7 @@
Responds to an Interaction.
If you have set to , You should use
- instead.
+ instead.
The text of the message to be sent.
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs
index 95157de89..aa42919b8 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs
@@ -18,10 +18,14 @@ namespace Discord.WebSocket
///
public IReadOnlyCollection Options { get; private set; }
- internal Dictionary guildMembers { get; private set; } = new();
- internal Dictionary users { get; private set; } = new();
- internal Dictionary channels { get; private set; } = new();
- internal Dictionary roles { get; private set; } = new();
+ internal Dictionary guildMembers { get; private set; }
+ = new Dictionary();
+ internal Dictionary users { get; private set; }
+ = new Dictionary();
+ internal Dictionary channels { get; private set; }
+ = new Dictionary();
+ internal Dictionary roles { get; private set; }
+ = new Dictionary();
private ulong? guildId;
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs
index c9e29599c..f611f773d 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs
@@ -24,14 +24,41 @@ namespace Discord.WebSocket
///
public IReadOnlyCollection Options { get; private set; }
-
- private SocketSlashCommandData data;
-
internal SocketSlashCommandDataOption() { }
internal SocketSlashCommandDataOption(SocketSlashCommandData data, Model model)
{
this.Name = model.Name;
- this.Value = model.Value.IsSpecified ? model.Value.Value : null;
+ this.Type = model.Type;
+
+ if (model.Value.IsSpecified)
+ {
+ if (ulong.TryParse($"{model.Value.Value}", out var valueId))
+ {
+ switch (this.Type)
+ {
+ case ApplicationCommandOptionType.User:
+ var guildUser = data.guildMembers.FirstOrDefault(x => x.Key == valueId).Value;
+
+ if (guildUser != null)
+ this.Value = guildUser;
+ else
+ this.Value = data.users.FirstOrDefault(x => x.Key == valueId).Value;
+
+ break;
+ case ApplicationCommandOptionType.Channel:
+ this.Value = data.channels.FirstOrDefault(x => x.Key == valueId).Value;
+ break;
+ case ApplicationCommandOptionType.Role:
+ this.Value = data.roles.FirstOrDefault(x => x.Key == valueId).Value;
+ break;
+ default:
+ this.Value = model.Value.Value;
+ break;
+ }
+ }
+ else
+ this.Value = model.Value.Value;
+ }
this.Options = model.Options.Any()
? model.Options.Select(x => new SocketSlashCommandDataOption(data, x)).ToImmutableArray()
@@ -46,48 +73,6 @@ namespace Discord.WebSocket
public static explicit operator string(SocketSlashCommandDataOption option)
=> option.Value.ToString();
- public static explicit operator SocketChannel(SocketSlashCommandDataOption option)
- {
- if(ulong.TryParse(option.Value.ToString(), out ulong id))
- {
- if (option.data.channels.TryGetValue(id, out var channel))
- return channel;
- }
-
- return null;
- }
-
- public static explicit operator SocketRole(SocketSlashCommandDataOption option)
- {
- if (ulong.TryParse(option.Value.ToString(), out ulong id))
- {
- if (option.data.roles.TryGetValue(id, out var role))
- return role;
- }
-
- return null;
- }
-
- public static explicit operator SocketUser(SocketSlashCommandDataOption option)
- {
- if (ulong.TryParse(option.Value.ToString(), out ulong id))
- {
- if (option.data.users.TryGetValue(id, out var user))
- return user;
- }
-
- return null;
- }
-
- public static explicit operator SocketGuildUser(SocketSlashCommandDataOption option)
- {
- if (option.Value as SocketUser is SocketGuildUser guildUser)
- return guildUser;
-
- return null;
- }
-
-
IReadOnlyCollection IApplicationCommandInteractionDataOption.Options => this.Options;
}
}
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
index 0876d6eb6..337f60f62 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
@@ -43,7 +43,9 @@ namespace Discord.WebSocket
///
public int Version { get; private set; }
- public DateTimeOffset CreatedAt { get; }
+ ///
+ public DateTimeOffset CreatedAt
+ => SnowflakeUtils.FromSnowflake(this.Id);
///
/// if the token is valid for replying to, otherwise .
@@ -52,7 +54,6 @@ namespace Discord.WebSocket
=> CheckToken();
private ulong? GuildId { get; set; }
- private ulong? ChannelId { get; set; }
internal SocketInteraction(DiscordSocketClient client, ulong id, ISocketMessageChannel channel)
: base(client, id)
@@ -77,7 +78,6 @@ namespace Discord.WebSocket
: null;
this.GuildId = model.GuildId.ToNullable();
- this.ChannelId = model.ChannelId.ToNullable();
this.Token = model.Token;
this.Version = model.Version;
this.Type = model.Type;
@@ -99,7 +99,7 @@ namespace Discord.WebSocket
/// Responds to an Interaction.
///
/// If you have set to , You should use
- /// instead.
+ /// instead.
///
///
/// The text of the message to be sent.
@@ -163,7 +163,7 @@ namespace Discord.WebSocket
private bool CheckToken()
{
// Tokens last for 15 minutes according to https://discord.com/developers/docs/interactions/slash-commands#responding-to-an-interaction
- return (DateTime.UtcNow - this.CreatedAt.UtcDateTime).TotalMinutes >= 15d;
+ return (DateTime.UtcNow - this.CreatedAt.UtcDateTime).TotalMinutes <= 15d;
}
}
}