Browse Source

Add missing methods to IComponentInteraction (#2201)

tags/3.5.0
d4n GitHub 3 years ago
parent
commit
741ed809d6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 15 deletions
  1. +20
    -1
      src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs
  2. +8
    -0
      src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs
  3. +2
    -14
      src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs

+ 20
- 1
src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs View File

@@ -1,3 +1,6 @@
using System;
using System.Threading.Tasks;

namespace Discord
{
/// <summary>
@@ -6,7 +9,7 @@ namespace Discord
public interface IComponentInteraction : IDiscordInteraction
{
/// <summary>
/// Gets the data received with this interaction, contains the button that was clicked.
/// Gets the data received with this component interaction.
/// </summary>
new IComponentInteractionData Data { get; }

@@ -14,5 +17,21 @@ namespace Discord
/// Gets the message that contained the trigger for this interaction.
/// </summary>
IUserMessage Message { get; }

/// <summary>
/// Updates the message which this component resides in with the type <see cref="InteractionResponseType.UpdateMessage"/>
/// </summary>
/// <param name="func">A delegate containing the properties to modify the message with.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>A task that represents the asynchronous operation of updating the message.</returns>
Task UpdateAsync(Action<MessageProperties> func, RequestOptions options = null);

/// <summary>
/// Defers an interaction with the response type 5 (<see cref="InteractionResponseType.DeferredChannelMessageWithSource"/>).
/// </summary>
/// <param name="ephemeral"><see langword="true"/> to defer ephemerally, otherwise <see langword="false"/>.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>A task that represents the asynchronous operation of acknowledging the interaction.</returns>
Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null);
}
}

+ 8
- 0
src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs View File

@@ -492,5 +492,13 @@ namespace Discord.Rest

/// <inheritdoc/>
IUserMessage IComponentInteraction.Message => Message;

/// <inheritdoc />
Task IComponentInteraction.UpdateAsync(Action<MessageProperties> func, RequestOptions options)
=> Task.FromResult(Update(func, options));

/// <inheritdoc />
Task IComponentInteraction.DeferLoadingAsync(bool ephemeral, RequestOptions options)
=> Task.FromResult(DeferLoading(ephemeral, options));
}
}

+ 2
- 14
src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs View File

@@ -202,12 +202,7 @@ namespace Discord.WebSocket
HasResponded = true;
}

/// <summary>
/// Updates the message which this component resides in with the type <see cref="InteractionResponseType.UpdateMessage"/>
/// </summary>
/// <param name="func">A delegate containing the properties to modify the message with.</param>
/// <param name="options">The request options for this <see langword="async"/> request.</param>
/// <returns>A task that represents the asynchronous operation of updating the message.</returns>
/// <inheritdoc/>
public async Task UpdateAsync(Action<MessageProperties> func, RequestOptions options = null)
{
var args = new MessageProperties();
@@ -383,14 +378,7 @@ namespace Discord.WebSocket
return await InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options).ConfigureAwait(false);
}

/// <summary>
/// Defers an interaction and responds with type 5 (<see cref="InteractionResponseType.DeferredChannelMessageWithSource"/>)
/// </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 <see langword="async"/> request.</param>
/// <returns>
/// A task that represents the asynchronous operation of acknowledging the interaction.
/// </returns>
/// <inheritdoc/>
public async Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null)
{
if (!InteractionHelper.CanSendResponse(this))


Loading…
Cancel
Save