Documentation ¶
Index ¶
- Variables
- func Action(action func(Context)) func(*Com)
- func Disabled(disabled bool) func(*Com)
- func EmptyOptionFunc(b *Bot) error
- func Name(name string) func(*Com)
- func Trigger(trigger string) func(*Com)
- func Use(use string) func(*Com)
- type Bot
- type Com
- type Command
- type Context
- func (ctx *Context) Error(err error)
- func (ctx *Context) GetVoiceConn(vs *discordgo.VoiceState, mute bool, deaf bool) (*discordgo.VoiceConnection, error)
- func (ctx *Context) GetVoiceState() (*discordgo.VoiceState, error)
- func (ctx *Context) JoinVoiceChannel(mute bool, deaf bool) (*discordgo.VoiceConnection, error)
- func (ctx *Context) SendEmbed(embed *discordgo.MessageEmbed) error
- func (ctx *Context) SendMessage(message string) error
- type OptionFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrVSNotFound is used when a voice state can't be found ErrVSNotFound = errors.New("Could not find user's voice state") // ErrDoubleCommand is used when 2 or more commands with the same trigger are added ErrDoubleCommand = errors.New("2 or more commands with the same trigger detected, only one of them will never be called") )
Functions ¶
func EmptyOptionFunc ¶
EmptyOptionFunc is a OptionFunc that does nothing it is used when an error occurs
Types ¶
type Bot ¶
type Bot struct { Mu sync.RWMutex Session *discordgo.Session Time time.Time ErrWriter io.Writer ErrPrefix func() string Prefix string Token string Commands map[string]Command }
Bot is a wrapper for a discordgo session
func (*Bot) AddCommand ¶
AddCommand adds a command to the bot
func (*Bot) AddHandler ¶
func (b *Bot) AddHandler(handler interface{})
AddHandler adds a handler to the discordgo session
func (*Bot) UpdateStatus ¶
UpdateStatus sets the bot's status if game == "" then set status to active and not playing anything
type Com ¶
Com is a simple implementation of the Command interface
func NewCommand ¶
NewCommand creates a new command with the given options
type Command ¶
type Command interface { Action(Context) Disabled() bool Name() string Use() string Trigger() string }
Command describes a basic command
type Context ¶
type Context struct { Bot *Bot Session *discordgo.Session MessageCreate *discordgo.MessageCreate Message string }
Context is a struct with data for commands
func (*Context) GetVoiceConn ¶
func (ctx *Context) GetVoiceConn(vs *discordgo.VoiceState, mute bool, deaf bool) (*discordgo.VoiceConnection, error)
GetVoiceConn joins the voice channel of the given voice state
func (*Context) GetVoiceState ¶
func (ctx *Context) GetVoiceState() (*discordgo.VoiceState, error)
GetVoiceState tries to get the voice state of the person who triggered the command
func (*Context) JoinVoiceChannel ¶
JoinVoiceChannel joins the voice channel of the person who triggered the command
func (*Context) SendEmbed ¶
func (ctx *Context) SendEmbed(embed *discordgo.MessageEmbed) error
SendEmbed sends a discordgo embed to the channel that triggerd the command
func (*Context) SendMessage ¶
SendMessage sends a message to the channel that triggerd the command
type OptionFunc ¶
OptionFunc is a option for the bot
func ErrPrefix ¶
func ErrPrefix(prefunc func() string) OptionFunc
ErrPrefix sets the function that will be called and prepended to the error
func ErrWriter ¶
func ErrWriter(w io.Writer) OptionFunc
ErrWriter sets the writer errors are written to