Class InteractionUtility
Utility class containing helper methods for interacting with Discord Interactions.
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public static class InteractionUtility : object
Methods
| Improve this Doc View SourceConfirmAsync(BaseSocketClient, IMessageChannel, TimeSpan, String, CancellationToken)
Create a confirmation dialog and wait for user input asynchronously.
Declaration
public static async Task<bool> ConfirmAsync(BaseSocketClient client, IMessageChannel channel, TimeSpan timeout, string message = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
BaseSocketClient | client | Client that should be listened to for the InteractionCreated event. |
IMessageChannel | channel | Send the confirmation prompt to this channel. |
TimeSpan | timeout | Timeout duration of this operation. |
String | message | Optional custom prompt message. |
CancellationToken | cancellationToken | Token for canceling the wait operation. |
Returns
Type | Description |
---|---|
Task<Boolean> | A Task representing the asynchronous waiting operation with a |
WaitForInteractionAsync(BaseSocketClient, TimeSpan, Predicate<SocketInteraction>, CancellationToken)
Wait for an Interaction event for a given amount of time as an asynchronous operation.
Declaration
public static async Task<SocketInteraction> WaitForInteractionAsync(BaseSocketClient client, TimeSpan timeout, Predicate<SocketInteraction> predicate, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
BaseSocketClient | client | Client that should be listened to for the InteractionCreated event. |
TimeSpan | timeout | Timeout duration for this operation. |
Predicate<SocketInteraction> | predicate | Delegate for checking whether an Interaction meets the requirements. |
CancellationToken | cancellationToken | Token for canceling the wait operation. |
Returns
Type | Description |
---|---|
Task<SocketInteraction> | A Task representing the asynchronous waiting operation. If the user responded in the given amount of time, Task result contains the user response, otherwise the Task result is null. |
WaitForMessageComponentAsync(BaseSocketClient, IUserMessage, TimeSpan, CancellationToken)
Wait for an Message Component Interaction event for a given amount of time as an asynchronous operation .
Declaration
public static Task<SocketInteraction> WaitForMessageComponentAsync(BaseSocketClient client, IUserMessage fromMessage, TimeSpan timeout, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
BaseSocketClient | client | Client that should be listened to for the InteractionCreated event. |
IUserMessage | fromMessage | The message that ButtonExecuted or SelectMenuExecuted should originate from. |
TimeSpan | timeout | Timeout duration for this operation. |
CancellationToken | cancellationToken | Token for canceling the wait operation. |
Returns
Type | Description |
---|---|
Task<SocketInteraction> | A Task representing the asynchronous waiting operation with a IDiscordInteraction result, the result is null if the process timed out before receiving a valid Interaction. |