acceptmsg

package
v0.0.0-...-eb18d79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package acceptmsg provides a message model for discordgo which can be accepted or declined via message reactions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout = errors.New("timed out")
)

Functions

This section is empty.

Types

type AcceptMessage

type AcceptMessage struct {
	*discordgo.Message
	Session        *discordgo.Session
	Embed          *discordgo.MessageEmbed
	UserID         string
	DeleteMsgAfter bool
	AcceptFunc     ActionHandler
	DeclineFunc    ActionHandler
	// contains filtered or unexported fields
}

AcceptMessage extends discordgo.Message to build and send an AcceptMessage.

func New

func New() *AcceptMessage

New creates an empty instance of AcceptMessage.

func (*AcceptMessage) AsFollowUp

func (am *AcceptMessage) AsFollowUp(ctx ken.Context) (*AcceptMessage, error)

AsFollowUp pushes the accept messages as follow up message to the command context and sets up listener handlers for reactions.

func (*AcceptMessage) DeleteAfterAnswer

func (am *AcceptMessage) DeleteAfterAnswer() *AcceptMessage

DeleteAfterAnswer enables that the whole accept embed message is being deleted after users answer.

func (*AcceptMessage) DoOnAccept

func (am *AcceptMessage) DoOnAccept(onAccept ActionHandler) *AcceptMessage

DoOnAccept specifies the action handler executed on acception.

func (*AcceptMessage) DoOnDecline

func (am *AcceptMessage) DoOnDecline(onDecline ActionHandler) *AcceptMessage

DoOnDecline specifies the action handler executed on decline.

func (*AcceptMessage) Error

func (am *AcceptMessage) Error() error

Error blocks until either one of the action functions was called or until the accept message timed out. Then, it returns an error or nil.

func (*AcceptMessage) LockOnUser

func (am *AcceptMessage) LockOnUser(userID string) *AcceptMessage

LockOnUser specifies, that only reaction inputs from the defined user are accepted.

func (*AcceptMessage) Send

func (am *AcceptMessage) Send(chanID string) (*AcceptMessage, error)

Send pushes the accept message into the specified channel and sets up listener handlers for reactions.

func (*AcceptMessage) WithContent

func (am *AcceptMessage) WithContent(cont string) *AcceptMessage

WithContent creates an embed with default color and specified content as description and sets it as embed instance.

func (*AcceptMessage) WithEmbed

WithEmbed sets the Embed instance to be set.

func (*AcceptMessage) WithSession

func (am *AcceptMessage) WithSession(s *discordgo.Session) *AcceptMessage

WithSession sets the discordgo.Session instance.

func (*AcceptMessage) WithTimeout

func (am *AcceptMessage) WithTimeout(t time.Duration) *AcceptMessage

type ActionHandler

type ActionHandler func(*discordgo.Message) error

Directories

Path Synopsis
Package acceptmsg provides a message model for discordgo which can be accepted or declined via message reactions.
Package acceptmsg provides a message model for discordgo which can be accepted or declined via message reactions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL