Table of Contents

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 BaseSocketClient

Client that should be listened to for the InteractionCreated event.

channel IMessageChannel

Send the confirmation prompt to this channel.

timeout TimeSpan

Timeout duration of this operation.

message string

Optional custom prompt message.

cancellationToken CancellationToken

Token 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 BaseSocketClient

Client that should be listened to for the InteractionCreated event.

timeout TimeSpan

Timeout duration for this operation.

predicate Predicate<SocketInteraction>

Delegate for checking whether an Interaction meets the requirements.

cancellationToken CancellationToken

Token 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 BaseSocketClient

Client that should be listened to for the InteractionCreated event.

fromMessage IUserMessage

The message that ButtonExecuted or SelectMenuExecuted should originate from.

timeout TimeSpan

Timeout duration for this operation.

cancellationToken CancellationToken

Token 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.