package
0.0.0-20220314160706-fab16b28a978
Repository: https://github.com/adayoung/ada-bot.git
Documentation: pkg.go.dev

# README

Bot Reactions

Hi! It's easy to implement simple bot reactions! We have a lovely dispatcher to take care of the gory details as long as your code conforms to the following example:

package botReactions

import (
	"github.com/bwmarrin/discordgo"
)

/* // A bot reaction implements the following interface
type BotReaction interface {
	Help() string
	HelpDetail(*discordgo.Message) string
	Reaction(message *discordgo.Message, author *discordgo.Member) Reaction
}
*/

type ping struct {  
	Trigger string
}

// This should be a single line without \n breaks, it appears in !help
func (p *ping) Help() string {
	return "Pong!"
}

// This is detailed help and it's supposed to be invoked when people do !help <trigger>
func (p *ping) HelpDetail() string {
	return "Ima ping pong ball!"
}

// The actual reaction, the full message content is available in m.Content
// The returned reaction is sent to the channel where the trigger was seen
func (p *ping) Reaction(m *discordgo.Message, a *discordgo.Member, mType string) Reaction {
	// mType can be CREATE, UPDATE, or DELETE (of messages on Discord) at the moment
	// see botReactions.go for the full struct definition of Reaction
	return Reaction{Text: "Pong!"}
}

// Here's where you add your 'trigger' and register your reaction with the dispatcher
func init() {
	_ping := &ping{
		Trigger: "ping", // Yes, it's "ping" and NOT "!ping".
	}
	addReaction(_ping.Trigger, "CREATE", _ping) // the second argument is mType
}

Oh, there's a special wildcard trigger * for which reactions are ignored on channels (they still work on direct messages). Those are intended for things that like to log and process all incoming messages (e.g. - logger.go).

Have a look at the other reactions for more complex examples!

# Functions

GenHelp generates help text for all defined bot reactions.
GetReactions gets all bot reactions for the supplied message.

# Variables

No description provided by the author

# Structs

Reaction represents the bot's reaction on a given trigger string, a non-nil Timer can be used for delayed (re)execution.

# Interfaces

BotReaction interface is expected by the dispatcher to process message triggers.