@@ -32,11 +32,6 @@ namespace Discord | |||||
Preconditions.AtLeast(value.Length, 3, nameof(Name)); | Preconditions.AtLeast(value.Length, 3, nameof(Name)); | ||||
Preconditions.AtMost(value.Length, MaxNameLength, nameof(Name)); | Preconditions.AtMost(value.Length, MaxNameLength, nameof(Name)); | ||||
// Discord updated the docs, this regex prevents special characters like @!$%(... etc, | |||||
// https://discord.com/developers/docs/interactions/slash-commands#applicationcommand | |||||
if (!Regex.IsMatch(value, @"^[\w -]{3,32}$")) | |||||
throw new ArgumentException("Command name cannot contain any special characters or whitespaces!"); | |||||
_name = value; | _name = value; | ||||
} | } | ||||
} | } | ||||
@@ -32,11 +32,6 @@ namespace Discord | |||||
Preconditions.AtLeast(value.Length, 3, nameof(Name)); | Preconditions.AtLeast(value.Length, 3, nameof(Name)); | ||||
Preconditions.AtMost(value.Length, MaxNameLength, nameof(Name)); | Preconditions.AtMost(value.Length, MaxNameLength, nameof(Name)); | ||||
// Discord updated the docs, this regex prevents special characters like @!$%(... etc, | |||||
// https://discord.com/developers/docs/interactions/slash-commands#applicationcommand | |||||
if (!Regex.IsMatch(value, @"^[\w -]{3,32}$")) | |||||
throw new ArgumentException("Command name cannot contain any special characters or whitespaces!"); | |||||
_name = value; | _name = value; | ||||
} | } | ||||
} | } | ||||
@@ -16,7 +16,6 @@ namespace Discord.API | |||||
[JsonProperty("allowed_mentions")] | [JsonProperty("allowed_mentions")] | ||||
public Optional<AllowedMentions> AllowedMentions { get; set; } | public Optional<AllowedMentions> AllowedMentions { get; set; } | ||||
// New flags prop. this make the response "ephemeral". see https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata | |||||
[JsonProperty("flags")] | [JsonProperty("flags")] | ||||
public Optional<MessageFlags> Flags { get; set; } | public Optional<MessageFlags> Flags { get; set; } | ||||
@@ -3271,16 +3271,16 @@ | |||||
voice regions the guild can access. | voice regions the guild can access. | ||||
</returns> | </returns> | ||||
</member> | </member> | ||||
<member name="M:Discord.WebSocket.SocketGuild.DeleteSlashCommandsAsync(Discord.RequestOptions)"> | |||||
<member name="M:Discord.WebSocket.SocketGuild.DeleteApplicationCommandsAsync(Discord.RequestOptions)"> | |||||
<summary> | <summary> | ||||
Deletes all slash commands in the current guild. | |||||
Deletes all application commands in the current guild. | |||||
</summary> | </summary> | ||||
<param name="options">The options to be used when sending the request.</param> | <param name="options">The options to be used when sending the request.</param> | ||||
<returns> | <returns> | ||||
A task that represents the asynchronous delete operation. | A task that represents the asynchronous delete operation. | ||||
</returns> | </returns> | ||||
</member> | </member> | ||||
<member name="M:Discord.WebSocket.SocketGuild.GetSlashCommandsAsync(Discord.RequestOptions)"> | |||||
<member name="M:Discord.WebSocket.SocketGuild.GetApplicationCommandsAsync(Discord.RequestOptions)"> | |||||
<summary> | <summary> | ||||
Gets a collection of slash commands created by the current user in this guild. | Gets a collection of slash commands created by the current user in this guild. | ||||
</summary> | </summary> | ||||
@@ -3290,17 +3290,6 @@ | |||||
slash commands created by the current user. | slash commands created by the current user. | ||||
</returns> | </returns> | ||||
</member> | </member> | ||||
<member name="M:Discord.WebSocket.SocketGuild.GetSlashCommandAsync(System.UInt64,Discord.RequestOptions)"> | |||||
<summary> | |||||
Gets a slash command in the current guild. | |||||
</summary> | |||||
<param name="id">The unique identifier of the slash command.</param> | |||||
<param name="options">The options to be used when sending the request.</param> | |||||
<returns> | |||||
A task that represents the asynchronous get operation. The task result contains a | |||||
slash command created by the current user. | |||||
</returns> | |||||
</member> | |||||
<member name="M:Discord.WebSocket.SocketGuild.GetInvitesAsync(Discord.RequestOptions)"> | <member name="M:Discord.WebSocket.SocketGuild.GetInvitesAsync(Discord.RequestOptions)"> | ||||
<summary> | <summary> | ||||
Gets a collection of all invites in this guild. | Gets a collection of all invites in this guild. | ||||
@@ -3439,16 +3428,6 @@ | |||||
of webhooks found within the guild. | of webhooks found within the guild. | ||||
</returns> | </returns> | ||||
</member> | </member> | ||||
<member name="M:Discord.WebSocket.SocketGuild.GetApplicationCommandsAsync(Discord.RequestOptions)"> | |||||
<summary> | |||||
Gets this guilds slash commands commands | |||||
</summary> | |||||
<param name="options">The options to be used when sending the request.</param> | |||||
<returns> | |||||
A task that represents the asynchronous get operation. The task result contains a read-only collection | |||||
of application commands found within the guild. | |||||
</returns> | |||||
</member> | |||||
<member name="M:Discord.WebSocket.SocketGuild.GetEmotesAsync(Discord.RequestOptions)"> | <member name="M:Discord.WebSocket.SocketGuild.GetEmotesAsync(Discord.RequestOptions)"> | ||||
<inheritdoc /> | <inheritdoc /> | ||||
</member> | </member> | ||||
@@ -3672,7 +3651,7 @@ | |||||
</member> | </member> | ||||
<member name="P:Discord.WebSocket.SocketUserCommandData.Member"> | <member name="P:Discord.WebSocket.SocketUserCommandData.Member"> | ||||
<summary> | <summary> | ||||
The user used to run the command | |||||
Gets the user who this command targets. | |||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:Discord.WebSocket.SocketUserCommandData.Options"> | <member name="P:Discord.WebSocket.SocketUserCommandData.Options"> | ||||
@@ -1,4 +1,5 @@ | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | |||||
using Model = Discord.API.ApplicationCommandInteractionData; | using Model = Discord.API.ApplicationCommandInteractionData; | ||||
namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
@@ -9,9 +10,10 @@ namespace Discord.WebSocket | |||||
public class SocketUserCommandData : SocketCommandBaseData | public class SocketUserCommandData : SocketCommandBaseData | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// The user used to run the command | |||||
/// Gets the user who this command targets. | |||||
/// </summary> | /// </summary> | ||||
public SocketUser Member { get; private set; } | |||||
public SocketUser Member | |||||
=> (SocketUser)ResolvableData.GuildMembers.Values.FirstOrDefault() ?? ResolvableData.Users.Values.FirstOrDefault(); | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
/// <remarks> | /// <remarks> | ||||
@@ -103,13 +103,11 @@ namespace Discord.WebSocket | |||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified, | ||||
Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional<API.Embed[]>.Unspecified, | Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional<API.Embed[]>.Unspecified, | ||||
TTS = isTTS ? true : Optional<bool>.Unspecified, | TTS = isTTS ? true : Optional<bool>.Unspecified, | ||||
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified | |||||
Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified, | |||||
Flags = ephemeral ? MessageFlags.Ephemeral : Optional<MessageFlags>.Unspecified | |||||
} | } | ||||
}; | }; | ||||
if (ephemeral) | |||||
response.Data.Value.Flags = MessageFlags.Ephemeral; | |||||
await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); | await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); | ||||
} | } | ||||