Documentation ¶
Overview ¶
Integrated command handlers.
Event multiplexer.
Index ¶
- Variables
- type CommandCategory
- type CommandHandler
- type CommandHandlers
- type Context
- func (context *Context) GenerateGuildPrefix() string
- func (context *Context) GetMember(user string) *discordgo.Member
- func (context *Context) GetVoiceState() (*discordgo.VoiceState, bool)
- func (context *Context) HandleError(err error) bool
- func (context *Context) HasPermission(permission int) bool
- func (context *Context) IsAdministrator() bool
- func (context *Context) IsOperator() bool
- func (context *Context) MakeVoiceConnection() (*discordgo.VoiceConnection, error)
- func (context *Context) SendEmbed(embed *embedutil.Embed) *discordgo.Message
- func (context *Context) SendMessage(message string) *discordgo.Message
- func (context *Context) StitchFields(start int) string
- type Multiplexer
- func (mux *Multiplexer) MatchRoute(message string) (*Route, []string)
- func (mux *Multiplexer) OnGuildDelete(session *discordgo.Session, delete *discordgo.GuildDelete)
- func (mux *Multiplexer) OnGuildMemberAdd(session *discordgo.Session, add *discordgo.GuildMemberAdd)
- func (mux *Multiplexer) OnGuildMemberRemove(session *discordgo.Session, remove *discordgo.GuildMemberRemove)
- func (mux *Multiplexer) OnMessageCreate(session *discordgo.Session, create *discordgo.MessageCreate)
- func (mux *Multiplexer) Route(route *Route) *Route
- type Route
Constants ¶
This section is empty.
Variables ¶
var ( AudioCategory = NewCategory("Audio", "Audio related utilities.") ExperienceCategory = NewCategory("Experience", "Chat experience and ranking system.") ManualsCategory = NewCategory("Manuals", "The operation manual pager utility.") MediaCategory = NewCategory("Media", "Media related utilities.") ModerationCategory = NewCategory("Moderation", "Chat moderation utilities.") SystemCategory = NewCategory("System", "System-related utilities.") )
Define the categories here
var ( EventHandlers []interface{} Router = New() NotTargeted []interface{} GuildMemberAdd []interface{} GuildMemberRemove []interface{} GuildDelete []interface{} )
var Categories = []*CommandCategory{AudioCategory, ExperienceCategory, ManualsCategory, MediaCategory, ModerationCategory, SystemCategory}
Functions ¶
This section is empty.
Types ¶
type CommandCategory ¶
Command categories
func NewCategory ¶
func NewCategory(name string, description string) *CommandCategory
Returns a new command category
type CommandHandler ¶
type CommandHandler func(*Context)
Function signature for functions that handle commands
type Context ¶
type Context struct { Message *discordgo.Message Session *discordgo.Session Guild *discordgo.Guild Author *discordgo.User Create *discordgo.MessageCreate Fields []string Content string IsPrivate bool IsTargeted bool HasPrefix bool HasMention bool HasLeadingMention bool }
Context information passed to the handlers
func (*Context) GenerateGuildPrefix ¶
GenerateGuildPrefix returns the command prefix of a context.
func (*Context) GetVoiceState ¶
func (context *Context) GetVoiceState() (*discordgo.VoiceState, bool)
GetVoiceState returns the voice state of a user if found.
func (*Context) HandleError ¶
HandleError handles a returned error and send the information of it if in debug mode.
func (*Context) HasPermission ¶
HasPermission checks a user for a permission.
func (*Context) IsAdministrator ¶
IsAdministrator checks of a user is the system administrator.
func (*Context) IsOperator ¶
IsOperator checks of a user is an operator.
func (*Context) MakeVoiceConnection ¶
func (context *Context) MakeVoiceConnection() (*discordgo.VoiceConnection, error)
MakeVoiceConnection returns the voice connection to a user's voice channel if join-able.
func (*Context) SendEmbed ¶
SendEmbed sends an embedutil message in the current channel and returns the message.
func (*Context) SendMessage ¶
SendMessage sends a text message in the current channel and returns the message.
func (*Context) StitchFields ¶
StitchFields stitches together fields of the message.
type Multiplexer ¶
Structure the multiplexer
func (*Multiplexer) MatchRoute ¶
func (mux *Multiplexer) MatchRoute(message string) (*Route, []string)
This matches routes for the message
func (*Multiplexer) OnGuildDelete ¶
func (mux *Multiplexer) OnGuildDelete(session *discordgo.Session, delete *discordgo.GuildDelete)
Event handler that fires when a guild is deleted
func (*Multiplexer) OnGuildMemberAdd ¶
func (mux *Multiplexer) OnGuildMemberAdd(session *discordgo.Session, add *discordgo.GuildMemberAdd)
Event handler that fires when a guild member is added
func (*Multiplexer) OnGuildMemberRemove ¶
func (mux *Multiplexer) OnGuildMemberRemove(session *discordgo.Session, remove *discordgo.GuildMemberRemove)
Event handler that fires when a guild member is removed
func (*Multiplexer) OnMessageCreate ¶
func (mux *Multiplexer) OnMessageCreate(session *discordgo.Session, create *discordgo.MessageCreate)
DiscordGo library event handler registered into the session
type Route ¶
type Route struct { Pattern string AliasPatterns []string Description string Category *CommandCategory Handler CommandHandler }
Information about a handler