msgcollector

package
v0.0.0-...-553821e Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package msgcollector provides functionalities to collect messages in a channel in conect of a single command request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageCollector

type MessageCollector struct {
	// contains filtered or unexported fields
}

MessageCollector provides functionalities to collect sent messages in a channel and matching them by a specified filter function.

func New

func New(s *discordgo.Session, channelID string, filter func(*discordgo.Message) bool, options *Options) (*MessageCollector, error)

New creates a new instance of MessageCollector using the passed Session s, channelID, filter function and options.

func (*MessageCollector) Close

func (mc *MessageCollector) Close(reason string)

Close unregisters the message create event listener, sets the status of the message collector to closed and removed all collected messages if set in options.

func (*MessageCollector) CollectedMatches

func (mc *MessageCollector) CollectedMatches() []*discordgo.Message

CollectedMatches returns the array of collected messages which went positively through the specified filter function.

func (*MessageCollector) CollectedMessages

func (mc *MessageCollector) CollectedMessages() []*discordgo.Message

CollectedMessages returns the array of collected messages.

func (*MessageCollector) IsClosed

func (mc *MessageCollector) IsClosed() bool

IsClosed returns the current closed status of the message collector.

func (*MessageCollector) OnClosed

func (mc *MessageCollector) OnClosed(handler func(string, *MessageCollector))

OnClosed is called when the message collector was closed actively or automatically getting passed the reason why the message collector was closed.

func (*MessageCollector) OnColelcted

func (mc *MessageCollector) OnColelcted(handler func(*discordgo.Message, *MessageCollector))

OnColelcted sets a handler function which is called everytime any message was collected in the specified channel.

func (*MessageCollector) OnMatched

func (mc *MessageCollector) OnMatched(handler func(*discordgo.Message, *MessageCollector))

OnMatched sets a handler function which is called everytime a message was collected which went positively through the specified match filter.

type Options

type Options struct {
	MaxMessages        int
	MaxMatches         int
	Timeout            time.Duration
	DeleteMatchesAfter bool
}

Options for MessageCollector initialization.

Jump to

Keyboard shortcuts

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