Documentation ¶
Overview ¶
Package multiplexer does command related stuff.
Index ¶
- Variables
- type CommandCategory
- type CommandHandler
- type Context
- func (context *Context) Ban(query string) error
- func (context *Context) GetChannel(query string) *discordgo.Channel
- func (context *Context) GetMember(query string) *discordgo.Member
- func (context *Context) GetRole(query string) *discordgo.Role
- 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) NumericalRegex() *regexp.Regexp
- func (context *Context) Prefix() string
- func (context *Context) SendEmbed(message string, embed embedutil.Embed) *discordgo.Message
- func (context *Context) SendMessage(message string) *discordgo.Message
- func (context *Context) StitchFields(start int) string
- type Multiplexer
- 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.") )
Predefined command categories.
var ( EventHandlers []interface{} NotTargeted []func(context *Context) Ready []func(session *discordgo.Session, ready *discordgo.Ready) GuildMemberAdd []func(session *discordgo.Session, add *discordgo.GuildMemberAdd) GuildMemberRemove []func(session *discordgo.Session, remove *discordgo.GuildMemberRemove) GuildDelete []func(session *discordgo.Session, delete *discordgo.GuildDelete) MessageCreate []func(session *discordgo.Session, create *discordgo.MessageCreate) MessageDelete []func(session *discordgo.Session, delete *discordgo.MessageDelete) MessageUpdate []func(session *discordgo.Session, update *discordgo.MessageUpdate) MessageReactionAdd []func(session *discordgo.Session, add *discordgo.MessageReactionAdd) MessageReactionRemove []func(session *discordgo.Session, remove *discordgo.MessageReactionRemove) )
Slice of event handlers.
var Categories = []*CommandCategory{AudioCategory, ExperienceCategory, ManualsCategory, MediaCategory, ModerationCategory, SystemCategory}
Categories is a slice of pointers to command categories.
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound represents the error returned when a user is not found.
var Router = New()
Router is the command router instance.
Functions ¶
This section is empty.
Types ¶
type CommandCategory ¶
CommandCategory represents a category of Route.
func NewCategory ¶
func NewCategory(name string, description string) *CommandCategory
NewCategory returns a new command category
type CommandHandler ¶
type CommandHandler func(*Context)
CommandHandler represents the handler function of a Route.
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 holds information of an event.
func (*Context) GetChannel ¶ added in v1.9.0
GetChannel gets a channel from a string representing it.
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) NumericalRegex ¶ added in v1.9.1
NumericalRegex returns a compiled regular expression that matches only numbers.
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 ¶
Multiplexer represents the command router.
func (*Multiplexer) MatchRoute ¶
func (mux *Multiplexer) MatchRoute(message string) (*Route, []string)
MatchRoute fuzzy matches a message to a route.
func (*Multiplexer) Route ¶
func (mux *Multiplexer) Route(route *Route) *Route
Route registers a route to the router.
type Route ¶
type Route struct { Pattern string AliasPatterns []string Description string Category *CommandCategory Handler CommandHandler }
Route represents a command route.