Documentation
¶
Index ¶
- type TimeoutError
- type Waiter
- func (w *Waiter) Await(timeout time.Duration) (discord.APIEmoji, error)
- func (w *Waiter) AwaitContext(ctx context.Context) (discord.APIEmoji, error)
- func (w *Waiter) Clone() (cp *Waiter)
- func (w *Waiter) InChannel(id discord.ChannelID) *Waiter
- func (w *Waiter) NoAutoDelete() *Waiter
- func (w *Waiter) NoAutoReact() *Waiter
- func (w *Waiter) WithCancelReactions(reactions ...discord.APIEmoji) *Waiter
- func (w *Waiter) WithMiddlewares(middlewares ...interface{}) *Waiter
- func (w *Waiter) WithReactions(reactions ...discord.APIEmoji) *Waiter
- func (w *Waiter) WithUser(id discord.UserID) *Waiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimeoutError ¶
type TimeoutError struct { UserID discord.UserID // Cause contains the cause of the TimeoutError. // Currently, this will only be filled, if a context.Context expires, while // awaiting a message or reaction. // Should that be the case, Cause will hold ctx.Err(). // // If Cause is nil, it can be assumed that the timeout was reached // regularly, i.e. by the user stopping to type. Cause error }
TimeoutError is an error that fulfills errors.As for *errors.UserInfo.
func (*TimeoutError) As ¶
func (e *TimeoutError) As(target interface{}) bool
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
func (*TimeoutError) Unwrap ¶
func (e *TimeoutError) Unwrap() error
Unwrap returns the cause for the timeout. Refer to the documentation for Cause for more information.
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
A Waiter is used to await reactions. Wait can either be cancelled by the user through a cancel reaction, or by the Waiter if the timeout expires.
func New ¶
New creates a new Waiter using the passed state.State and plugin.Context. ctx.Author will be assumed as the user to make the reaction in ctx.ChannelID.
func (*Waiter) Await ¶
Await creates a context.Context with the given timeout and calls AwaitContext with it.
func (*Waiter) AwaitContext ¶
AwaitContext awaits a reaction of the user until they signal cancellation, the timeout expires or the context expires.
If the user cancels the wait or deletes the message, errors.Abort will be returned. Furthermore, if the guild, channel or message becomes unavailable while adding reactions, errors.Abort will be returned as well. If the context expires, a *TimeoutError with Cause set to ctx.Err() will be returned.
Besides that, the wait can also be canceled through a middleware.
func (*Waiter) NoAutoDelete ¶
NoAutoDelete disables the automatic deletion of the reactions.
func (*Waiter) NoAutoReact ¶
NoAutoReact disables automatic reaction and deletion of the reactions.
func (*Waiter) WithCancelReactions ¶
WithCancelReactions adds the passed cancel reactions. If the user reacts with one of the passed emojis, AwaitReply will return errors.Abort.
func (*Waiter) WithMiddlewares ¶
WithMiddlewares adds the passed middlewares to the waiter. All middlewares of invalid type will be discarded.
The following types are permitted:
- func(*state.State, interface{})
- func(*state.State, interface{}) error
- func(*state.State, *event.Base)
- func(*state.State, *event.Base) error
- func(*state.State, *state.MessageReactionAddEvent)
- func(*state.State, *state.MessageReactionAddEvent) error
func (*Waiter) WithReactions ¶
WithReactions adds the passed reaction to the wait list.