Documentation
¶
Index ¶
- Constants
- type Command
- type Config
- type Context
- func (ctx Context) SendEmbed(embed *discordgo.MessageEmbed) (*discordgo.Message, error)
- func (ctx Context) SendErrorMessage(format string, a ...interface{}) (*discordgo.Message, error)
- func (ctx Context) SendInfoMessage(format string, a ...interface{}) (*discordgo.Message, error)
- func (ctx Context) SendMessage(color int, title, format string, a ...interface{}) (*discordgo.Message, error)
- func (ctx Context) SendSuccessMessage(format string, a ...interface{}) (*discordgo.Message, error)
- type Module
- type Snorlax
Constants ¶
const ( SuccessColor int = 5025616 ErrorColor int = 16007990 InfoColor int = 2201331 )
This is a collection of the standard colors used for messages.
const Version = "0.1.0"
Version is the bot version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Command string Alias string Desc string Usage string ModuleName string Handler func(*Context) }
Command holds the data and handler for a command.
type Config ¶
type Config struct { // AutoDelete determines whether or not to automatically delete command // messages. AutoDelete bool `json:"autoDelete"` DBPath string `json:"dbPath"` Debug bool `json:"debug"` DisplayAuthor bool `json:"displayAuthor"` Token string `json:"token"` Owners []string `json:"owners"` }
Config is the configuration struct for the Snorlax bot.
func ParseConfig ¶
ParseConfig parses a config file, and returns a new Config.
func (*Config) UpdateFile ¶
UpdateFile will update the config.json file.
type Context ¶
type Context struct { Log *logrus.Logger Session *discordgo.Session Message *discordgo.MessageCreate Snorlax *Snorlax State *discordgo.State ChannelID string }
Context is the context for command handlers. It serves as a way to unify styles and ease development.
func (Context) SendErrorMessage ¶
SendErrorMessage is a quick way to send an error. -scrapped- It will suffix the message with a mention to the message creator.
func (Context) SendInfoMessage ¶
SendInfoMessage is a shortcut for sending a message with the info colors.
type Module ¶
Module is used to import a modular package into the bot. This serves to make the bot modular and expandable.
type Snorlax ¶
type Snorlax struct { Commands map[string]*Command Modules map[string]*Module Session *discordgo.Session Log *logrus.Logger Mutex *sync.Mutex DB *sql.DB Config *Config }
Snorlax is the bot type.
func (*Snorlax) Close ¶
func (s *Snorlax) Close()
Close closes the Discord session, and exits the app.
func (*Snorlax) ConnDB ¶
func (s *Snorlax) ConnDB()
ConnDB intializes the connection to the SQLite database.
func (*Snorlax) InitDB ¶
func (s *Snorlax) InitDB()
InitDB will create the initial tables and rows of the database.
func (*Snorlax) RegisterModule ¶
RegisterModule allows you to register a module to expand the bot.
func (*Snorlax) RegisterModules ¶
RegisterModules registers a list of modules.