parsley

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
var ErrHandlerInvalidParameterCount error = errors.New("provided command handler expects incorrect number of parameters")

ErrHandlerInvalidParameterCount occurs when a provided handler does not expect two parameters.

View Source
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.

View Source
var ErrHandlerNotFunction error = errors.New("provided command handler is not a function")

ErrHandlerNotFunction occurs when a provided handler is not a function.

View Source
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

View Source
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.

View Source
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 New

func New(prefix string) *Parser

New creates a new Parsley parser.

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

func (parser *Parser) NewCommand(name, description string, handler interface{}) error

NewCommand registers a new command with the command parser.

func (*Parser) RegisterHandler

func (parser *Parser) RegisterHandler(session *discordgo.Session)

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.

Directories

Path Synopsis
example module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL