Documentation
¶
Index ¶
- Variables
- type ArgumentDetails
- type Command
- type CommandDetails
- type Parser
- func (parser *Parser) GetCommand(commandName string) (CommandDetails, error)
- func (parser *Parser) GetCommands() []CommandDetails
- func (parser *Parser) NewCommand(name, description string, handler interface{}) error
- func (parser *Parser) RegisterHandler(session *discordgo.Session)
- func (parser *Parser) RunCommand(message *discordgo.MessageCreate) error
Constants ¶
This section is empty.
Variables ¶
var ErrHandlerInvalidFirstParameterType error = errors.New("incorrect first parameter type for handler, first parameter must be of type *discordgo.MessageCreate")
ErrHandlerInvalidFirstParameterType occurs when a provided handler does not expect a first parameter of the correct type.
var ErrHandlerInvalidParameterCount error = errors.New("provided command handler expects incorrect number of parameters")
ErrHandlerInvalidParameterCount occurs when a provided handler does not expect two parameters.
var ErrHandlerInvalidSecondParameterType error = errors.New("incorrect second parameter type for handler, second parameter must be of type struct")
ErrHandlerInvalidSecondParameterType occurs when a provided handler does not expect a second parameter of the correct type.
var ErrHandlerNotFunction error = errors.New("provided command handler is not a function")
ErrHandlerNotFunction occurs when a provided handler is not a function.
var ErrKwargsMustBeAtEnd error = errors.New("keyword arguments must be provided as the last arguments")
ErrKwargsMustBeAtEnd occurs when a user provides keyword arguments in the middle of positional arguments
var ErrRequiredArgumentMissing error = errors.New("one or more required arguments were not provided")
ErrRequiredArgumentMissing occurs when the provided message does not have values for all required arguments.
var ErrUnknownCommand error = errors.New("unknown command")
ErrUnknownCommand occurs when the provided message or function call contains an unknown command.
Functions ¶
This section is empty.
Types ¶
type ArgumentDetails ¶
type ArgumentDetails struct { Name string Type string Description string Required bool Default string }
ArgumentDetails represents the details of an individual command argument.
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents an individual Discord command.
type CommandDetails ¶
type CommandDetails struct { Name string Description string Arguments []ArgumentDetails }
CommandDetails represents the parsed details of an individual command.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a parser for Discord commands.
func (*Parser) GetCommand ¶
func (parser *Parser) GetCommand(commandName string) (CommandDetails, error)
GetCommand retrieves the details of an individual command.
func (*Parser) GetCommands ¶
func (parser *Parser) GetCommands() []CommandDetails
GetCommands parses all registered commands and returns details related to each of them.
func (*Parser) NewCommand ¶
NewCommand registers a new command with the command parser.
func (*Parser) RegisterHandler ¶
RegisterHandler registers a simpler handler on a discordgo session to automatically parse incoming messages for you.
func (*Parser) RunCommand ¶
func (parser *Parser) RunCommand(message *discordgo.MessageCreate) error
RunCommand parses the content of a specific message and runs the associated command, if found.