Browse Source

Fix some bugs

pull/1923/head
quin lynch 3 years ago
parent
commit
8b5d5724c9
6 changed files with 10 additions and 42 deletions
  1. +0
    -5
      src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs
  2. +0
    -5
      src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs
  3. +0
    -1
      src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs
  4. +4
    -25
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
  5. +4
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommandData.cs
  6. +2
    -4
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs

+ 0
- 5
src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs View File

@@ -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;
}
}


+ 0
- 5
src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs View File

@@ -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;
}
}


+ 0
- 1
src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs View File

@@ -16,7 +16,6 @@ namespace Discord.API
[JsonProperty("allowed_mentions")]
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")]
public Optional<MessageFlags> Flags { get; set; }



+ 4
- 25
src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml View File

@@ -3271,16 +3271,16 @@
voice regions the guild can access.
</returns>
</member>
<member name="M:Discord.WebSocket.SocketGuild.DeleteSlashCommandsAsync(Discord.RequestOptions)">
<member name="M:Discord.WebSocket.SocketGuild.DeleteApplicationCommandsAsync(Discord.RequestOptions)">
<summary>
Deletes all slash commands in the current guild.
Deletes all application commands in the current guild.
</summary>
<param name="options">The options to be used when sending the request.</param>
<returns>
A task that represents the asynchronous delete operation.
</returns>
</member>
<member name="M:Discord.WebSocket.SocketGuild.GetSlashCommandsAsync(Discord.RequestOptions)">
<member name="M:Discord.WebSocket.SocketGuild.GetApplicationCommandsAsync(Discord.RequestOptions)">
<summary>
Gets a collection of slash commands created by the current user in this guild.
</summary>
@@ -3290,17 +3290,6 @@
slash commands created by the current user.
</returns>
</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)">
<summary>
Gets a collection of all invites in this guild.
@@ -3439,16 +3428,6 @@
of webhooks found within the guild.
</returns>
</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)">
<inheritdoc />
</member>
@@ -3672,7 +3651,7 @@
</member>
<member name="P:Discord.WebSocket.SocketUserCommandData.Member">
<summary>
The user used to run the command
Gets the user who this command targets.
</summary>
</member>
<member name="P:Discord.WebSocket.SocketUserCommandData.Options">


+ 4
- 2
src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommandData.cs View File

@@ -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
{
/// <summary>
/// The user used to run the command
/// Gets the user who this command targets.
/// </summary>
public SocketUser Member { get; private set; }
public SocketUser Member
=> (SocketUser)ResolvableData.GuildMembers.Values.FirstOrDefault() ?? ResolvableData.Users.Values.FirstOrDefault();

/// <inheritdoc/>
/// <remarks>


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

@@ -103,13 +103,11 @@ namespace Discord.WebSocket
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional<API.Embed[]>.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);
}



Loading…
Cancel
Save