diff --git a/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs index 9907dd2cf..801aca302 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs @@ -32,11 +32,6 @@ namespace Discord Preconditions.AtLeast(value.Length, 3, 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; } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs index d415a99a6..5629a7014 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs @@ -32,11 +32,6 @@ namespace Discord Preconditions.AtLeast(value.Length, 3, 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; } } diff --git a/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs index ba233cc6b..2101f79f4 100644 --- a/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs +++ b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs @@ -16,7 +16,6 @@ namespace Discord.API [JsonProperty("allowed_mentions")] public Optional 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")] public Optional Flags { get; set; } diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index faacf90ab..1a7504102 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -3271,16 +3271,16 @@ voice regions the guild can access. - + - Deletes all slash commands in the current guild. + Deletes all application commands in the current guild. The options to be used when sending the request. A task that represents the asynchronous delete operation. - + Gets a collection of slash commands created by the current user in this guild. @@ -3290,17 +3290,6 @@ slash commands created by the current user. - - - Gets a slash command in the current guild. - - The unique identifier of the slash command. - The options to be used when sending the request. - - A task that represents the asynchronous get operation. The task result contains a - slash command created by the current user. - - Gets a collection of all invites in this guild. @@ -3439,16 +3428,6 @@ of webhooks found within the guild. - - - Gets this guilds slash commands commands - - The options to be used when sending the request. - - A task that represents the asynchronous get operation. The task result contains a read-only collection - of application commands found within the guild. - - @@ -3672,7 +3651,7 @@ - The user used to run the command + Gets the user who this command targets. diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommandData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommandData.cs index 70eb4adff..d6c2a7990 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommandData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommandData.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Model = Discord.API.ApplicationCommandInteractionData; namespace Discord.WebSocket @@ -9,9 +10,10 @@ namespace Discord.WebSocket public class SocketUserCommandData : SocketCommandBaseData { /// - /// The user used to run the command + /// Gets the user who this command targets. /// - public SocketUser Member { get; private set; } + public SocketUser Member + => (SocketUser)ResolvableData.GuildMembers.Values.FirstOrDefault() ?? ResolvableData.Users.Values.FirstOrDefault(); /// /// diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs index 7c8e2422e..8ca20aa7c 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs @@ -103,13 +103,11 @@ namespace Discord.WebSocket AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, 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 + Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, + Flags = ephemeral ? MessageFlags.Ephemeral : Optional.Unspecified } }; - if (ephemeral) - response.Data.Value.Flags = MessageFlags.Ephemeral; - await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); }