Browse Source

resolved #88

pull/1923/head
quin lynch 4 years ago
parent
commit
75892660d0
6 changed files with 25 additions and 40 deletions
  1. +1
    -1
      src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs
  2. +1
    -1
      src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs
  3. +7
    -16
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
  4. +7
    -11
      src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs
  5. +5
    -9
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs
  6. +4
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs

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

@@ -18,7 +18,7 @@ namespace Discord.API

// New flags prop. this make the response "ephemeral". see https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
[JsonProperty("flags")]
public Optional<int> Flags { get; set; }
public Optional<MessageFlags> Flags { get; set; }

[JsonProperty("components")]
public Optional<API.ActionRowComponent[]> Components { get; set; }


+ 1
- 1
src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs View File

@@ -28,7 +28,7 @@ namespace Discord.API.Rest
public Optional<AllowedMentions> AllowedMentions { get; set; }

[JsonProperty("flags")]
public Optional<int> Flags { get; set; }
public Optional<MessageFlags> Flags { get; set; }

[JsonProperty("components")]
public Optional<API.ActionRowComponent[]> Components { get; set; }


+ 7
- 16
src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml View File

@@ -3628,14 +3628,8 @@
<member name="M:Discord.WebSocket.SocketMessageComponent.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)">
<inheritdoc/>
</member>
<member name="M:Discord.WebSocket.SocketMessageComponent.DeferAsync(Discord.RequestOptions)">
<summary>
Acknowledges this interaction with the <see cref="F:Discord.InteractionResponseType.DeferredUpdateMessage"/>.
</summary>
<param name="options">The request options for this async request.</param>
<returns>
A task that represents the asynchronous operation of acknowledging the interaction.
</returns>
<member name="M:Discord.WebSocket.SocketMessageComponent.DeferAsync(System.Boolean,Discord.RequestOptions)">
<inheritdoc/>
</member>
<member name="T:Discord.WebSocket.SocketMessageComponentData">
<summary>
@@ -3747,13 +3741,8 @@
<member name="M:Discord.WebSocket.SocketSlashCommand.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)">
<inheritdoc/>
</member>
<member name="M:Discord.WebSocket.SocketSlashCommand.DeferAsync(Discord.RequestOptions)">
<summary>
Acknowledges this interaction with the <see cref="F:Discord.InteractionResponseType.DeferredChannelMessageWithSource"/>.
</summary>
<returns>
A task that represents the asynchronous operation of acknowledging the interaction.
</returns>
<member name="M:Discord.WebSocket.SocketSlashCommand.DeferAsync(System.Boolean,Discord.RequestOptions)">
<inheritdoc/>
</member>
<member name="T:Discord.WebSocket.SocketSlashCommandData">
<summary>
@@ -3888,10 +3877,12 @@
A task that represents the asynchronous operation of acknowledging the interaction.
</returns>
</member>
<member name="M:Discord.WebSocket.SocketInteraction.DeferAsync(Discord.RequestOptions)">
<member name="M:Discord.WebSocket.SocketInteraction.DeferAsync(System.Boolean,Discord.RequestOptions)">
<summary>
Acknowledges this interaction.
</summary>
<param name="ephemeral"><see langword="true"/> to send this message ephemerally, otherwise <see langword="false"/>.</param>
<param name="options">The request options for this async request.</param>
<returns>
A task that represents the asynchronous operation of acknowledging the interaction.
</returns>


+ 7
- 11
src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs View File

@@ -123,7 +123,7 @@ namespace Discord.WebSocket
};

if (ephemeral)
response.Data.Value.Flags = 64;
response.Data.Value.Flags = MessageFlags.Ephemeral;

await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options);
}
@@ -180,7 +180,7 @@ namespace Discord.WebSocket
Components = args.Components.IsSpecified
? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray()
: Optional<API.ActionRowComponent[]>.Unspecified,
Flags = args.Flags.IsSpecified ? (int?)args.Flags.Value ?? Optional<int>.Unspecified : Optional<int>.Unspecified
Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional<MessageFlags>.Unspecified : Optional<MessageFlags>.Unspecified
}
};

@@ -217,23 +217,19 @@ namespace Discord.WebSocket
};

if (ephemeral)
args.Flags = 64;
args.Flags = MessageFlags.Ephemeral;

return await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
}

/// <summary>
/// Acknowledges this interaction with the <see cref="InteractionResponseType.DeferredUpdateMessage"/>.
/// </summary>
/// <param name="options">The request options for this async request.</param>
/// <returns>
/// A task that represents the asynchronous operation of acknowledging the interaction.
/// </returns>
public override Task DeferAsync(RequestOptions options = null)
/// <inheritdoc/>
public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
{
var response = new API.InteractionResponse()
{
Type = InteractionResponseType.DeferredUpdateMessage,
Data = ephemeral ? new API.InteractionCallbackData() { Flags = MessageFlags.Ephemeral } : Optional<API.InteractionCallbackData>.Unspecified

};

return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options);


+ 5
- 9
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs View File

@@ -106,7 +106,7 @@ namespace Discord.WebSocket
};

if (ephemeral)
response.Data.Value.Flags = 64;
response.Data.Value.Flags = MessageFlags.Ephemeral;

await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options);
}
@@ -141,22 +141,18 @@ namespace Discord.WebSocket
};

if (ephemeral)
args.Flags = 64;
args.Flags = MessageFlags.Ephemeral;

return await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
}

/// <summary>
/// Acknowledges this interaction with the <see cref="InteractionResponseType.DeferredChannelMessageWithSource"/>.
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation of acknowledging the interaction.
/// </returns>
public override Task DeferAsync(RequestOptions options = null)
/// <inheritdoc/>
public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
{
var response = new API.InteractionResponse
{
Type = InteractionResponseType.DeferredChannelMessageWithSource,
Data = ephemeral ? new API.InteractionCallbackData() { Flags = MessageFlags.Ephemeral } : Optional<API.InteractionCallbackData>.Unspecified
};

return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options);


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

@@ -156,15 +156,17 @@ namespace Discord.WebSocket
/// A task that represents the asynchronous operation of acknowledging the interaction.
/// </returns>
[Obsolete("This method deprecated, please use DeferAsync instead")]
public Task AcknowledgeAsync(RequestOptions options = null) => DeferAsync(options);
public Task AcknowledgeAsync(RequestOptions options = null) => DeferAsync(options: options);

/// <summary>
/// Acknowledges this interaction.
/// </summary>
/// <param name="ephemeral"><see langword="true"/> to send this message ephemerally, otherwise <see langword="false"/>.</param>
/// <param name="options">The request options for this async request.</param>
/// <returns>
/// A task that represents the asynchronous operation of acknowledging the interaction.
/// </returns>
public abstract Task DeferAsync(RequestOptions options = null);
public abstract Task DeferAsync(bool ephemeral = false, RequestOptions options = null);

private bool CheckToken()
{


Loading…
Cancel
Save