disgoreact

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2020 License: MIT Imports: 3 Imported by: 0

README

disgoreact

Similar to disgomux, this is just a small personal library for turning Discord reactions into functional buttons with DiscordGo.

Todo

  • Better documentation
  • Efficency tweaks

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	// A unicode representation of the emoji option
	Emoji string
	// OnSucess is the function to call every time MinClicks has been met on the given emoji
	OnSucess func(user *discordgo.User, watchContext *WatchContext)
	// OnError is the function to call when the watcher or poller encounters an error
	OnError func(err error, watchContext *WatchContext)
	// ReactionLimit is the cap for the total number of reactions polled
	ReactionLimit int
	// Expiration as a Timer
	Expiration time.Duration
}

Option contains a callback and expiration for a given emoji

type WatchContext

type WatchContext struct {
	// Message is a DiscordGo Message object pointer
	Message *discordgo.Message
	// Session is a DiscordGo Session object pointer
	Session *discordgo.Session
	// TickRate is how frequently to poll the reactions on the message
	TickRate time.Duration
	// Data (for lack of a better name). An interface for storing just about anything
	Data interface{}
}

WatchContext contains the objects and tickrate needed to watch a message

func NewWatcher

func NewWatcher(
	message *discordgo.Message,
	session *discordgo.Session,
	tickRate time.Duration,
	data interface{},
) (*WatchContext, error)

NewWatcher creates a new WatchContext

func (*WatchContext) Add

func (ctx *WatchContext) Add(options ...Option) error

Add adds watchers to the given WatchContext corresponding to the given reaction. Reactions are specified as an array of Options.

Jump to

Keyboard shortcuts

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