Class InteractionUtility
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.WebSocket.dll
Utility class containing helper methods for interacting with Discord Interactions.
public static class InteractionUtility
- Inheritance
-
InteractionUtility
- Inherited Members
Methods
ConfirmAsync(BaseSocketClient, IMessageChannel, TimeSpan, string, CancellationToken)
Create a confirmation dialog and wait for user input asynchronously.
public static Task<bool> ConfirmAsync(BaseSocketClient client, IMessageChannel channel, TimeSpan timeout, string message = null, CancellationToken cancellationToken = default)
Parameters
client
BaseSocketClientClient that should be listened to for the InteractionCreated event.
channel
IMessageChannelSend the confirmation prompt to this channel.
timeout
TimeSpanTimeout duration of this operation.
message
stringOptional custom prompt message.
cancellationToken
CancellationTokenToken for canceling the wait operation.
Returns
- Task<bool>
A Task representing the asynchronous waiting operation with a bool result, the result is false if the user declined the prompt or didnt answer in time, true if the user confirmed the prompt.
WaitForInteractionAsync(BaseSocketClient, TimeSpan, Predicate<SocketInteraction>, CancellationToken)
Wait for an Interaction event for a given amount of time as an asynchronous operation.
public static Task<SocketInteraction> WaitForInteractionAsync(BaseSocketClient client, TimeSpan timeout, Predicate<SocketInteraction> predicate, CancellationToken cancellationToken = default)
Parameters
client
BaseSocketClientClient that should be listened to for the InteractionCreated event.
timeout
TimeSpanTimeout duration for this operation.
predicate
Predicate<SocketInteraction>Delegate for checking whether an Interaction meets the requirements.
cancellationToken
CancellationTokenToken for canceling the wait operation.
Returns
- 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 .
public static Task<SocketInteraction> WaitForMessageComponentAsync(BaseSocketClient client, IUserMessage fromMessage, TimeSpan timeout, CancellationToken cancellationToken = default)
Parameters
client
BaseSocketClientClient that should be listened to for the InteractionCreated event.
fromMessage
IUserMessageThe message that ButtonExecuted or SelectMenuExecuted should originate from.
timeout
TimeSpanTimeout duration for this operation.
cancellationToken
CancellationTokenToken for canceling the wait operation.
Returns
- 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.