Documentation
¶
Index ¶
- Variables
- func NewCommand(name string) *builder
- func RequiresMinArgs(n uint) func(args []string) error
- func RequiresMulti(f ...func(args []string) error) func(args []string) error
- func RequiresPositionalArgs(p map[string]uint) func(args []string) error
- type Command
- func (cmd *Command) AddChild(child *Command) error
- func (cmd *Command) FindChild(name ...string) (*Command, error)
- func (cmd *Command) GetArgs() []string
- func (cmd *Command) GetInbound() chan<- *discordgo.Message
- func (cmd *Command) GetReader() io.Reader
- func (cmd *Command) GetWriter() io.Writer
- func (cmd *Command) ParseArgs(args []string) []string
- func (cmd *Command) RemoveAllChildren()
- func (cmd *Command) RemoveChild(name string) (*Command, error)
- func (cmd Command) Root() (root *Command, err error)
- func (cmd *Command) Run(p *Provider, ctx context.Context, input []string) (*Command, error)
- func (cmd *Command) RunConcurrently(p *Provider, ctx context.Context, input []string) (c *Command, errReturn chan error)
- func (cmd *Command) SetArgs(args ...string)
- func (cmd *Command) SetReader(r io.Reader)
- func (cmd *Command) SetWriter(w io.Writer)
- func (cmd *Command) ThreadSafe() (Command, error)
- func (cmd *Command) WriteString(s string)
- type Provider
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotImplemented = errors.New("not implemented") ErrChildIsNil = errors.New("child is nil") ErrChildAlreadyAdded = errors.New("child already added") ErrChildNotFound = errors.New("child not found") ErrLoopedChildren = errors.New("child-parent loop exists") ErrNoMessageAvailable = errors.New("no message available") ErrTooFewArguments = errors.New("too few arguments") ErrCouldNotRunCommand = errors.New("could not run command") ErrPositionalArgsMisplaced = errors.New("args in incorrect place") )
Functions ¶
func NewCommand ¶
func NewCommand(name string) *builder
func RequiresMinArgs ¶
Types ¶
type Command ¶
type Command struct {
Name string
Short string
Parent *Command
PreExecute func(cmd *Command, ctx context.Context, p *Provider) error
Execute func(cmd *Command, ctx context.Context, p *Provider) error
PostExecute func(cmd *Command, ctx context.Context, p *Provider) error
Validate func(args []string) error
CaptureInput bool
// contains filtered or unexported fields
}
func (*Command) AddChild ¶
Adds a child to the command node, and sets the child's parent to be the command node.
Will return ErrChildAlreadyAdded if the child already has been added to the node.
func (*Command) GetInbound ¶
func (*Command) RemoveAllChildren ¶
func (cmd *Command) RemoveAllChildren()
func (*Command) RunConcurrently ¶
func (*Command) ThreadSafe ¶
Creates a threadsafe version of the command. This command is effectively a deep copy of the original command, But still retains a pointer to its original parent and children Such that only one command is initialized instead of the entire tree
func (*Command) WriteString ¶
Click to show internal directories.
Click to hide internal directories.