Documentation ¶
Index ¶
- type CheckError
- type Command
- type CommandArg
- type CommandCheck
- type CommandCtx
- type CommandRouter
- func (r CommandRouter) AddCommand(comm Command)
- func (r CommandRouter) GetCommand(name string) (Command, bool)
- func (r CommandRouter) GetCommandList() []Command
- func (r CommandRouter) GetCommandNameList() []string
- func (r CommandRouter) ProcessCommands(prefix string, session *discordgo.Session, message *discordgo.MessageCreate) (*ProcessResult, error)
- type ConversionError
- type Converter
- type ConverterCtx
- type Ctx
- type MissingRequiredArgumentError
- type ProcessResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckError ¶
type CheckError struct { // the check that failed Check *CommandCheck }
returned when a command check fails
func (CheckError) Error ¶
func (e CheckError) Error() string
type Command ¶
type Command struct { Name string Description string Args []CommandArg Aliases []string NoJoin bool Checks []CommandCheck Callback func(*CommandCtx) }
represents a command that users can use
type CommandArg ¶
argument for a command
type CommandCheck ¶
a callback that decides whether a command can be run or not
type CommandCtx ¶
type CommandCtx struct { *Ctx Args []interface{} }
stores contextual information for a command such as arguments, session and message
type CommandRouter ¶
type CommandRouter struct {
// contains filtered or unexported fields
}
stores command routes
func (CommandRouter) AddCommand ¶
func (r CommandRouter) AddCommand(comm Command)
adds a command to the command router's map
func (CommandRouter) GetCommand ¶
func (r CommandRouter) GetCommand(name string) (Command, bool)
fetches a command from the command router's map via name
func (CommandRouter) GetCommandList ¶ added in v1.0.1
func (r CommandRouter) GetCommandList() []Command
returns all command objects - use GetCommandNameList to get list of only command names
func (CommandRouter) GetCommandNameList ¶ added in v1.0.1
func (r CommandRouter) GetCommandNameList() []string
returns all command names in lowercase - use GetCommandList to return all command objects
func (CommandRouter) ProcessCommands ¶
func (r CommandRouter) ProcessCommands(prefix string, session *discordgo.Session, message *discordgo.MessageCreate) (*ProcessResult, error)
uses the prefix of the bot, session and message object in order to determine the handler and context of the command
type ConversionError ¶
type ConversionError struct { // The arg that the converter belongs to Arg *CommandArg // The input that failed to convert Input string // The position of the arg in the command arguments - indexed on 1 ArgPosition int }
returned when a converter doesn't convert input successfully
func (ConversionError) Error ¶
func (e ConversionError) Error() string
type Converter ¶
type Converter struct { Name string Callback func(*ConverterCtx) (interface{}, bool) }
a callback that "converts" a string input into something else
type ConverterCtx ¶
type ConverterCtx struct { *Ctx Arg *CommandArg Input string }
stores contextual information for a converter such as the argument, input, session and message
type Ctx ¶
type Ctx struct { Command *Command Session *discordgo.Session Message *discordgo.MessageCreate }
stores basic context
type MissingRequiredArgumentError ¶
type MissingRequiredArgumentError struct { Arg *CommandArg ArgPosition int }
returned when a required argument is missing
func (MissingRequiredArgumentError) Error ¶
func (e MissingRequiredArgumentError) Error() string
type ProcessResult ¶
type ProcessResult struct { // command that was processed from the message, nil if no command was found Command *Command // callback function that runs the command callback Callback func() }
the result of calling ProcessCommands, contains the handler for the function and command that was parsed