Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
type Args map[string]interface{}
Args is a set of args bound to identifiers that are parsed from the command
func NewArgs ¶
func NewArgs() Args
NewArgs makes a new instance of Args for storing key-argument mappings
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder generates the framework of a command.
type Command ¶
Command is used to handle a command which will only be run on a `*discordgo.MessageCreate` event. Encapsulates the implementation of both `Event` and `Parseable`.
`Match` is where a command with a trimmed prefix will be matched an alias. It returns an alias parsed from the command with an `ok` bool. If `ok` is false, the Command will immediately be terminated.
type Context ¶
type Context struct { Filter Session *discordgo.Session Message *discordgo.Message Prefix string Alias string Args Args Toks Toks Err error FmtFilterErr func(Filter) string // format a Filter into an error string }
Context contains data relating to the command invocation context
func NewContext ¶
func NewContext() Context
NewContext returns an unpopulated context with defaults set
type Event ¶
Event is used to handle a `*discordgo.MessageCreate` event. Only contains the core functions required to implement a `Command`, thus does not require a prefix or alias to be parsed. Can optionally implement `Parseable`, but is not required.
`Handle` is where a command's business logic should belong.
`Resolve` is where an error in `ctx.Err` can be handled, along with any other necessary cleanup. It will always be the last function run.
type Filter ¶
type Filter int
Filter represents a condition that prevents a `Command` or `Event` from firing. Only use the given const filters which range from 2^0 to 2^4.
Valid Filters
type FilterError ¶
type FilterError struct {
// contains filtered or unexported fields
}
FilterError is an error that has a failing Filter attached
func (*FilterError) Error ¶
func (e *FilterError) Error() string
func (*FilterError) Filter ¶
func (e *FilterError) Filter() Filter
Filter returns the violated filter
type Parseable ¶
Parseable represents an entity that can be parsed. It is implemented by `Command` but optional for `Event`
`Parse` is where `Toks` will be parsed into `Args`. If an error is non-nil, will immediately be handled by `Resolve(ctx Context)`
type Prefixer ¶
Prefixer identifies the prefix based on the guildID before a `Command` execution and removes the prefix of the command string if matched.
`Load` fetches a prefix that matches the `guildID` and returns the prefix mapped to the `guildID` with an `ok` bool.
`Default` returns the default prefix
type Router ¶
Router maps commands to handlers.
func (*Router) HandleDefault ¶
HandleDefault binds a default discordgo event handler to the builder.
func (*Router) Has ¶
Has binds a `Builder` to the router which should implement `Event` or `Command` with any desired `Filter` to control when the handler fires.
`Filter` has consts defined in the package that start with the prefix `Messages*`