Documentation ¶
Index ¶
- Variables
- type Argument
- func (argument *Argument) AsBool() (bool, error)
- func (argument *Argument) AsChannelMentionID() string
- func (argument *Argument) AsInt() (int, error)
- func (argument *Argument) AsInt64() (int64, error)
- func (argument *Argument) AsRoleMentionID() string
- func (argument *Argument) AsUserMentionID() string
- func (argument *Argument) Raw() string
- type Arguments
- type Codeblock
- type Command
- type Ctx
- type ExecutionHandler
- type Middleware
- type Router
- func (router *Router) AddMiddleware(flag string, middleware Middleware)
- func (router *Router) GetCmd(name string) *Command
- func (router *Router) Initialize(session *discordgo.Session)
- func (router *Router) RegisterCmd(command *Command)
- func (router *Router) RegisterDefaultHelpCommand(session *discordgo.Session)
Constants ¶
This section is empty.
Variables ¶
var ( // RegexArguments defines the regex the argument string has to match RegexArguments = regexp.MustCompile("(\"[^\"]+\"|[^\\s]+)") // RegexUserMention defines the regex a user mention has to match RegexUserMention = regexp.MustCompile("<@!?(\\d+)>") // RegexRoleMention defines the regex a role mention has to match RegexRoleMention = regexp.MustCompile("<@&(\\d+)>") // RegexChannelMention defines the regex a channel mention has to match RegexChannelMention = regexp.MustCompile("<#(\\d+)>") // RegexBigCodeblock defines the regex a big codeblock has to match RegexBigCodeblock = regexp.MustCompile("(?s)\\n*```(?:([\\w.\\-]*)\\n)?(.*)```") // RegexSmallCodeblock defines the regex a small codeblock has to match RegexSmallCodeblock = regexp.MustCompile("(?s)\\n*`(.*)`") // CodeblockLanguages defines which languages are valid codeblock languages CodeblockLanguages = []string{}/* 315 elements not displayed */ )
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
Argument represents a single argument
func (*Argument) AsChannelMentionID ¶
AsChannelMentionID returns the ID of the mentioned channel or an empty string if it is no mention
func (*Argument) AsRoleMentionID ¶
AsRoleMentionID returns the ID of the mentioned role or an empty string if it is no mention
func (*Argument) AsUserMentionID ¶
AsUserMentionID returns the ID of the mentioned user or an empty string if it is no mention
type Arguments ¶
type Arguments struct {
// contains filtered or unexported fields
}
Arguments represents the arguments that may be used in a command context
func ParseArguments ¶
ParseArguments parses the raw string into several arguments
func (*Arguments) AsCodeblock ¶
AsCodeblock parses the given arguments as a codeblock
type Command ¶
type Command struct { Name string Aliases []string Description string Usage string Example string Flags []string IgnoreCase bool SubCommands []*Command Handler ExecutionHandler }
Command represents a simple command
type Ctx ¶
type Ctx struct { Session *discordgo.Session Event *discordgo.MessageCreate Arguments *Arguments Router *Router Command *Command }
Ctx represents the context for a command event
type ExecutionHandler ¶
type ExecutionHandler func(*Ctx)
ExecutionHandler represents a handler for a context execution
type Router ¶
type Router struct { Prefixes []string IgnorePrefixCase bool BotsAllowed bool Commands []*Command Middlewares map[string][]Middleware PingHandler ExecutionHandler // contains filtered or unexported fields }
Router represents a DiscordGo command router
func (*Router) AddMiddleware ¶
func (router *Router) AddMiddleware(flag string, middleware Middleware)
AddMiddleware adds a new middleware
func (*Router) Initialize ¶
Initialize initializes the message event listener
func (*Router) RegisterCmd ¶
RegisterCmd registers a new command
func (*Router) RegisterDefaultHelpCommand ¶
RegisterDefaultHelpCommand registers the default help command