Documentation
¶
Overview ¶
Package sento is a discord bot framework.
Index ¶
- Variables
- type Bot
- func (bot *Bot) EmitEvent(eventType EventType, data interface{})
- func (b *Bot) LogError(msg string, fields ...LogField)
- func (b *Bot) LogInfo(msg string, fields ...LogField)
- func (bot *Bot) Send(info HandleInfo, message string) (err error)
- func (bot *Bot) Sess() *discordgo.Session
- func (bot *Bot) Start() (err error)
- func (bot *Bot) Stop() (err error)
- type Config
- type EventData
- type EventListener
- type EventType
- type HandleInfo
- type Handler
- type LogField
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultConfig for a discord bot DefaultConfig = Config{ Prefix: "#!", } )
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is a sento-powered bot application
type EventListener ¶
EventListener interface used for defining listeners
type EventType ¶
type EventType int
EventType indicates the supported event types
const ( // EventConnected emitted when the discord session opens EventConnected EventType = iota // EventMessageSent emitted when the bot sends a message EventMessageSent // EventMessageReceived emitted when the bot processes a message EventMessageReceived // EventDisconnected emitted when the discord session closes EventDisconnected )
type HandleInfo ¶
type HandleInfo struct {
Trigger string
GuildID string
ChannelID string
MessageID string
AuthorID string
MessageContent string
}
HandleInfo about a single trigger instance
type Handler ¶
type Handler interface {
// Name of the handler
Name() string
// Triggers for a given handler
Triggers() []string
// Handle the trigger instance
Handle(bot *Bot, info HandleInfo) error
// Start runs when the bot connection has been made
// and is adding all handlers
Start(bot *Bot) error
// Stop runs when the bot is being shut down
Stop(bot *Bot) error
}
Handler listens for an specific command and contain all the logic necesary for it
type Option ¶
Option for a sent-powered discord bot
func UseConfigFile ¶
UseConfigFile makes a robot use the indicated config file. Note that the config MUST be in TOML format.
func UseHandlers ¶
UseHandlers sets the handlers for a bot
func UseListeners ¶
func UseListeners(listeners ...EventListener) Option
UseListeners sets the listeners for a bot