Class MessageExtensions
Interactivity extension methods for DiscordMessage.
Inheritance
Namespace: DisCatSharp.Interactivity.Extensions
Assembly: DisCatSharp.Interactivity.dll
Syntax
public static class MessageExtensions
Methods
| Improve this Doc View SourceCollectReactionsAsync(DiscordMessage, Nullable<TimeSpan>)
Collects all reactions on this message within the timeout duration.
Declaration
public static Task<ReadOnlyCollection<Reaction>> CollectReactionsAsync(this DiscordMessage message, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to collect reactions from. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.ObjectModel.ReadOnlyCollection<Reaction>> |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if interactivity is not enabled for the client associated with the message. |
DoPollAsync(DiscordMessage, IEnumerable<DiscordEmoji>, Nullable<PollBehaviour>, Nullable<TimeSpan>)
Begins a poll using this message.
Declaration
public static Task<ReadOnlyCollection<PollEmoji>> DoPollAsync(this DiscordMessage message, IEnumerable<DiscordEmoji> emojis, PollBehaviour? behaviorOverride = null, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | Target message. |
System.Collections.Generic.IEnumerable<DiscordEmoji> | emojis | Options for this poll. |
System.Nullable<PollBehaviour> | behaviorOverride | Overrides the action set in PaginationBehaviour |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.ObjectModel.ReadOnlyCollection<PollEmoji>> |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if interactivity is not enabled for the client associated with the message. |
GetNextMessageAsync(DiscordMessage, Func<DiscordMessage, Boolean>, Nullable<TimeSpan>)
Waits for the next message with the same author and channel as this message, which also satisfies a predicate.
Declaration
public static Task<InteractivityResult<DiscordMessage>> GetNextMessageAsync(this DiscordMessage message, Func<DiscordMessage, bool> predicate, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | Original message. |
System.Func<DiscordMessage, System.Boolean> | predicate | A predicate that should return true if a message matches. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<DiscordMessage>> |
GetNextMessageAsync(DiscordMessage, Nullable<TimeSpan>)
Waits for the next message that has the same author and channel as this message.
Declaration
public static Task<InteractivityResult<DiscordMessage>> GetNextMessageAsync(this DiscordMessage message, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | Original message. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<DiscordMessage>> |
WaitForButtonAsync(DiscordMessage)
Waits for any button to be pressed on the specified message.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, DiscordUser, Nullable<TimeSpan>)
Waits for any button to be pressed on the specified message by the specified user.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, DiscordUser user, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
DiscordUser | user | The user to wait for button input from. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, DiscordUser, CancellationToken)
Waits for any button to be pressed on the specified message by the specified user.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, DiscordUser user, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
DiscordUser | user | The user to wait for button input from. |
System.Threading.CancellationToken | token | A custom cancellation token that can be cancelled at any point. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, Func<ComponentInteractionCreateEventArgs, Boolean>, Nullable<TimeSpan>)
Waits for any button to be interacted with.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, Func<ComponentInteractionCreateEventArgs, bool> predicate, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.Func<ComponentInteractionCreateEventArgs, System.Boolean> | predicate | The predicate to filter interactions by. |
System.Nullable<System.TimeSpan> | timeoutOverride | Override the timeout specified in InteractivityConfiguration |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, Func<ComponentInteractionCreateEventArgs, Boolean>, CancellationToken)
Waits for any button to be interacted with.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, Func<ComponentInteractionCreateEventArgs, bool> predicate, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.Func<ComponentInteractionCreateEventArgs, System.Boolean> | predicate | The predicate to filter interactions by. |
System.Threading.CancellationToken | token | A token to cancel interactivity with at any time. Pass System.Threading.CancellationToken.None to wait indefinitely. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, Nullable<TimeSpan>)
Waits for any button to be pressed on the specified message.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, String, Nullable<TimeSpan>)
Waits for a button with the specified Id to be pressed on the specified message.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, string id, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.String | id | The Id of the button to wait for. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, String, CancellationToken)
Waits for a button with the specified Id to be pressed on the specified message.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, string id, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.String | id | The Id of the button to wait for. |
System.Threading.CancellationToken | token | A custom cancellation token that can be cancelled at any point. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForButtonAsync(DiscordMessage, CancellationToken)
Waits for any button to be pressed on the specified message.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForButtonAsync(this DiscordMessage message, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.Threading.CancellationToken | token | A custom cancellation token that can be cancelled at any point. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForReactionAsync(DiscordMessage, DiscordUser, DiscordEmoji, Nullable<TimeSpan>)
Waits for a specific reaction on this message from the specified user.
Declaration
public static Task<InteractivityResult<MessageReactionAddEventArgs>> WaitForReactionAsync(this DiscordMessage message, DiscordUser user, DiscordEmoji emoji, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | Target message. |
DiscordUser | user | The target user. |
DiscordEmoji | emoji | The target emoji. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<MessageReactionAddEventArgs>> |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if interactivity is not enabled for the client associated with the message. |
WaitForReactionAsync(DiscordMessage, DiscordUser, Nullable<TimeSpan>)
Waits for a reaction on this message from a specific user.
Declaration
public static Task<InteractivityResult<MessageReactionAddEventArgs>> WaitForReactionAsync(this DiscordMessage message, DiscordUser user, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | Target message. |
DiscordUser | user | The target user. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<MessageReactionAddEventArgs>> |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if interactivity is not enabled for the client associated with the message. |
WaitForSelectAsync(DiscordMessage, DiscordUser, String, Nullable<TimeSpan>)
Waits for a dropdown to be interacted with by the specified user.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForSelectAsync(this DiscordMessage message, DiscordUser user, string id, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
DiscordUser | user | The user to wait for. |
System.String | id | The Id of the dropdown to wait for. |
System.Nullable<System.TimeSpan> | timeoutOverride |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForSelectAsync(DiscordMessage, DiscordUser, String, CancellationToken)
Waits for a dropdown to be interacted with by the specified user.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForSelectAsync(this DiscordMessage message, DiscordUser user, string id, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
DiscordUser | user | The user to wait for. |
System.String | id | The Id of the dropdown to wait for. |
System.Threading.CancellationToken | token | A custom cancellation token that can be cancelled at any point. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForSelectAsync(DiscordMessage, Func<ComponentInteractionCreateEventArgs, Boolean>, Nullable<TimeSpan>)
Waits for any dropdown to be interacted with.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForSelectAsync(this DiscordMessage message, Func<ComponentInteractionCreateEventArgs, bool> predicate, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait for. |
System.Func<ComponentInteractionCreateEventArgs, System.Boolean> | predicate | A filter predicate. |
System.Nullable<System.TimeSpan> | timeoutOverride | Override the timeout period specified in InteractivityConfiguration. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the message doesn't contain any dropdowns |
WaitForSelectAsync(DiscordMessage, Func<ComponentInteractionCreateEventArgs, Boolean>, CancellationToken)
Waits for any dropdown to be interacted with.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForSelectAsync(this DiscordMessage message, Func<ComponentInteractionCreateEventArgs, bool> predicate, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait for. |
System.Func<ComponentInteractionCreateEventArgs, System.Boolean> | predicate | A filter predicate. |
System.Threading.CancellationToken | token | A token that can be used to cancel interactivity. Pass System.Threading.CancellationToken.None to wait indefinitely. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the message doesn't contain any dropdowns |
WaitForSelectAsync(DiscordMessage, String, Nullable<TimeSpan>)
Waits for a dropdown to be interacted with.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForSelectAsync(this DiscordMessage message, string id, TimeSpan? timeoutOverride = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.String | id | The Id of the dropdown to wait for. |
System.Nullable<System.TimeSpan> | timeoutOverride | Overrides the timeout set in Timeout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |
WaitForSelectAsync(DiscordMessage, String, CancellationToken)
Waits for a dropdown to be interacted with.
Declaration
public static Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForSelectAsync(this DiscordMessage message, string id, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to wait on. |
System.String | id | The Id of the dropdown to wait for. |
System.Threading.CancellationToken | token | A custom cancellation token that can be cancelled at any point. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<InteractivityResult<ComponentInteractionCreateEventArgs>> |