command

package
v0.0.0-...-9ab1851 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2018 License: MIT Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCall

func DefaultCall(c *Command, ctx *context.Context) (string, error)

func DefaultHelp

func DefaultHelp(c *Command, ctx *context.Context) (string, error)

func DefaultUnload

func DefaultUnload(c *Command) error

Types

type AllowedChatType

type AllowedChatType int
const (
	AllowedChatTypeAll AllowedChatType = iota
	AllowedChatTypeGuildOnly
	AllowedChatTypeDMOnly
)

type Command

type Command struct {
	UsageDoc string
	ShortDoc string
	LongDoc  string

	Name     string
	Aliases  []string
	Category string // *Category ?
	// bot_perms  []*Permission
	// user_perms []*Permission
	MinArgs int
	// flags      []*FlagOptions
	AllowedChatType AllowedChatType
	Nsfw            bool
	Hidden          bool
	Disabled        bool
	// events     ???
	IsSubCommand bool

	CallFunc   func(*Command, *context.Context) (string, error)
	HelpFunc   func(*Command, *context.Context) (string, error)
	UnloadFUnc func(*Command) error

	Bot        *bot.Bot
	CommandMap *map[string]*Command // TODO: pointer to habdler
	// contains filtered or unexported fields
}

Command represents bot command

func New

func New(b *bot.Bot, name string, commands *map[string]*Command) *Command

Returns new command with most important fields filled

func NewSubcommand

func NewSubcommand(b *bot.Bot, name string, commands *map[string]*Command, parent *Command) *Command

Returns new subcommand with most important fields filled

func (*Command) Build

func (c *Command) Build()

Builds command

func (*Command) Call

func (c *Command) Call(ctx *context.Context) (string, error)

func (*Command) Help

func (c *Command) Help(ctx *context.Context) (string, error)

func (*Command) Unload

func (c *Command) Unload() error

Jump to

Keyboard shortcuts

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