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
messageDiscordMessageThe message to wait on.
buttonsIEnumerable<DiscordButtonComponent>A collection of buttons to listen for.
timeoutOverrideTimeSpan?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
messageDiscordMessageThe message to wait on.
buttonsIEnumerable<DiscordButtonComponent>A collection of buttons to listen for.
tokenCancellationTokenA 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
messageDiscordMessageThe message to wait for the button on.
timeoutOverrideTimeSpan?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
messageDiscordMessageThe message to wait for the button on.
tokenCancellationTokenA 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
messageDiscordMessageThe message to wait for the button on.
userDiscordUserThe user to wait for the button press from.
timeoutOverrideTimeSpan?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
messageDiscordMessageThe message to wait for the button on.
userDiscordUserThe user to wait for the button press from.
tokenCancellationTokenA 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
messageDiscordMessageThe message to wait for the button on.
idstringThe Id of the button to wait for.
timeoutOverrideTimeSpan?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
messageDiscordMessageThe message to wait for the button on.
idstringThe Id of the button to wait for.
tokenCancellationTokenCancellation 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
messageDiscordMessageThe message to wait on.
predicateFunc<ComponentInteractionCreatedEventArgs, bool>The predicate to filter interactions by.
timeoutOverrideTimeSpan?Override the timeout specified in InteractivityConfiguration
Returns
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
messageDiscordMessageThe message to wait on.
predicateFunc<ComponentInteractionCreatedEventArgs, bool>The predicate to filter interactions by.
tokenCancellationTokenA token to cancel interactivity with at any time. Pass None to wait indefinitely.