Table of Contents

Method WaitForButtonAsync

Namespace
DSharpPlus.Interactivity
Assembly
DSharpPlus.Interactivity.dll

WaitForButtonAsync(DiscordMessage, IEnumerable<DiscordButtonComponent>, TimeSpan?)

Waits for any button in the specified collection to be pressed.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, IEnumerable<DiscordButtonComponent> buttons, TimeSpan? timeoutOverride = null)

Parameters

message DiscordMessage

The message to wait on.

buttons IEnumerable<DiscordButtonComponent>

A collection of buttons to listen for.

timeoutOverride TimeSpan?

Override the timeout period in InteractivityConfiguration.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of button that was pressed, if any.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, IEnumerable<DiscordButtonComponent>, CancellationToken)

Waits for any button in the specified collection to be pressed.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, IEnumerable<DiscordButtonComponent> buttons, CancellationToken token)

Parameters

message DiscordMessage

The message to wait on.

buttons IEnumerable<DiscordButtonComponent>

A collection of buttons to listen for.

token CancellationToken

A custom cancellation token that can be cancelled at any point.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of button that was pressed, if any.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, TimeSpan?)

Waits for any button on the specified message to be pressed.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, TimeSpan? timeoutOverride = null)

Parameters

message DiscordMessage

The message to wait for the button on.

timeoutOverride TimeSpan?

Override the timeout period specified in InteractivityConfiguration.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of button that was pressed, if any.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, CancellationToken)

Waits for any button on the specified message to be pressed.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, CancellationToken token)

Parameters

message DiscordMessage

The message to wait for the button on.

token CancellationToken

A custom cancellation token that can be cancelled at any point.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of button that was pressed, if any.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, DiscordUser, TimeSpan?)

Waits for any button on the specified message to be pressed by the specified user.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, DiscordUser user, TimeSpan? timeoutOverride = null)

Parameters

message DiscordMessage

The message to wait for the button on.

user DiscordUser

The user to wait for the button press from.

timeoutOverride TimeSpan?

Override the timeout period specified in InteractivityConfiguration.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of button that was pressed, if any.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, DiscordUser, CancellationToken)

Waits for any button on the specified message to be pressed by the specified user.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, DiscordUser user, CancellationToken token)

Parameters

message DiscordMessage

The message to wait for the button on.

user DiscordUser

The user to wait for the button press from.

token CancellationToken

A custom cancellation token that can be cancelled at any point.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of button that was pressed, if any.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, string, TimeSpan?)

Waits for a button with the specified Id to be pressed.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, string id, TimeSpan? timeoutOverride = null)

Parameters

message DiscordMessage

The message to wait for the button on.

id string

The Id of the button to wait for.

timeoutOverride TimeSpan?

Override the timeout period specified in InteractivityConfiguration.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of the operation.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, string, CancellationToken)

Waits for a button with the specified Id to be pressed.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, string id, CancellationToken token)

Parameters

message DiscordMessage

The message to wait for the button on.

id string

The Id of the button to wait for.

token CancellationToken

Cancellation token.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

A InteractivityResult<T> with the result of the operation.

Exceptions

InvalidOperationException

Thrown when attempting to wait for a message that is not authored by the current user.

ArgumentException

Thrown when the message does not contain a button with the specified Id, or any buttons at all.

WaitForButtonAsync(DiscordMessage, Func<ComponentInteractionCreatedEventArgs, bool>, TimeSpan?)

Waits for any button to be interacted with.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, Func<ComponentInteractionCreatedEventArgs, bool> predicate, TimeSpan? timeoutOverride = null)

Parameters

message DiscordMessage

The message to wait on.

predicate Func<ComponentInteractionCreatedEventArgs, bool>

The predicate to filter interactions by.

timeoutOverride TimeSpan?

Override the timeout specified in InteractivityConfiguration

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>

WaitForButtonAsync(DiscordMessage, Func<ComponentInteractionCreatedEventArgs, bool>, CancellationToken)

Waits for any button to be interacted with.

public Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> WaitForButtonAsync(DiscordMessage message, Func<ComponentInteractionCreatedEventArgs, bool> predicate, CancellationToken token)

Parameters

message DiscordMessage

The message to wait on.

predicate Func<ComponentInteractionCreatedEventArgs, bool>

The predicate to filter interactions by.

token CancellationToken

A token to cancel interactivity with at any time. Pass None to wait indefinitely.

Returns

Task<InteractivityResult<ComponentInteractionCreatedEventArgs>>