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
clientBaseSocketClientClient that should be listened to for the InteractionCreated event.
channelIMessageChannelSend the confirmation prompt to this channel.
timeoutTimeSpanTimeout duration of this operation.
messagestringOptional custom prompt message.
cancellationTokenCancellationTokenToken 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
clientBaseSocketClientClient that should be listened to for the InteractionCreated event.
timeoutTimeSpanTimeout duration for this operation.
predicatePredicate<SocketInteraction>Delegate for checking whether an Interaction meets the requirements.
cancellationTokenCancellationTokenToken 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
clientBaseSocketClientClient that should be listened to for the InteractionCreated event.
fromMessageIUserMessageThe message that ButtonExecuted or SelectMenuExecuted should originate from.
timeoutTimeSpanTimeout duration for this operation.
cancellationTokenCancellationTokenToken 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.