Documentation ¶
Index ¶
- func RBuildHelp(c *Context, builder *strings.Builder, cmds []*Command, depth int)
- type Command
- type Context
- func (ctx *Context) DB() *db.WadlDB
- func (ctx *Context) ReplyError(err error) bool
- func (ctx *Context) ReplyHelp() *discordgo.Message
- func (ctx *Context) ReplyString(message string) *discordgo.Message
- func (ctx *Context) ReplyStringf(format string, a ...interface{}) *discordgo.Message
- func (ctx *Context) ReplyTimeDeleteStringf(delay time.Duration, format string, a ...interface{})
- type ContextExecutor
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct { //Name is the primary trigger and is used for each level of a permission node Name string Aliases []string Description string //Usage format: http://docopt.org/ Usage string //HideInHelp whether or not this should be hidden from the help command. HideInHelp bool SubCommands []*Command Handler ContextExecutor }
Command holds information about a command and what to do
func (*Command) GeneratePermissionNode ¶
GeneratePermissionNode recursivly generates permission nodes for this and all subcommands and returns them
func (*Command) HasSubcommands ¶
HasSubcommands returns whether or not this command holds subcommands
func (*Command) SPrintHelp ¶
SPrintHelp returns the command's Usage and Description formatted in a nice way
type Context ¶
type Context struct { //The current discordgo.Session Session *discordgo.Session //The message that started this execution Message *discordgo.MessageCreate //The command being executed Command *Command //Command args (i.e. the split message content) Args []string //The router currently used Router *Router }
Context holds all state for a command's execution
func (*Context) ReplyError ¶
ReplyError returns a generic error to the user
func (*Context) ReplyString ¶
ReplyString replies to the contextual channel with the string provided. returns nil if an error occured while sending the message
func (*Context) ReplyStringf ¶
ReplyStringf replies to the contextual channel with the string provided
type ContextExecutor ¶
type ContextExecutor func(*Context)
ContextExecutor represents an executor for a context execution
type Router ¶
type Router struct { Commands []*Command Prefix string WadlDB *db.WadlDB PermSystem *permissions.PermissionSystem Config *cfg.Config }
Router is the central command multiplexer
func BuildRouter ¶
func BuildRouter(wdb *db.WadlDB, permSystem *permissions.PermissionSystem, cfg *cfg.Config) Router
BuildRouter returns a fully built router stuct with commands preregistered
func (*Router) Handler ¶
func (r *Router) Handler() func(*discordgo.Session, *discordgo.MessageCreate)
Handler returns the func that deals with command delegates execution to command
func (*Router) RegisterCommands ¶
RegisterCommands adds a command(s) to the Router
func (*Router) SetupPermissions ¶
func (r *Router) SetupPermissions()
SetupPermissions generates permission nodes and adds references in the permission system