Documentation ¶
Index ¶
- Constants
- Variables
- type Argument
- type Context
- func (c *Context) Arg(name string) string
- func (c *Context) BoolArg(name string) bool
- func (c *Context) ChannelArg(name string) *discordgo.Channel
- func (c *Context) ChannelArgType(name string, t discordgo.ChannelType) *discordgo.Channel
- func (c *Context) FloatArg(name string) float64
- func (c *Context) Get(key string) interface{}
- func (c *Context) IntArg(name string) int64
- func (c *Context) Reply(text string) (*discordgo.Message, error)
- func (c *Context) ReplyEmbed(embed *discordgo.MessageEmbed) (*discordgo.Message, error)
- func (c *Context) ReplyFile(name string, r io.Reader) (*discordgo.Message, error)
- func (c *Context) ReplyTo(to, text string) (*discordgo.Message, error)
- func (c *Context) Replyf(format string, a ...interface{}) (*discordgo.Message, error)
- func (c *Context) Send(text string) (*discordgo.Message, error)
- func (c *Context) SendFile(name string, r io.Reader) (*discordgo.Message, error)
- func (c *Context) Sendf(format string, a ...interface{}) (*discordgo.Message, error)
- func (c *Context) Set(key string, d interface{})
- func (c *Context) Usage(usage ...string) (*discordgo.Message, error)
- func (c *Context) UserArg(name string) *discordgo.User
- type FindOpts
- type Handler
- type MiddlewareFunc
- type Route
- func (r *Route) Add(n *Route) *Route
- func (r *Route) Alias(alias string) *Route
- func (r *Route) Call(ctx *Context) error
- func (r *Route) Desc(description string) *Route
- func (r *Route) Find(args ...string) *Route
- func (r *Route) FindComplex(opts FindOpts) *Route
- func (r *Route) Group(fn func(*Route)) *Route
- func (r *Route) On(signature string, f Handler) *Route
- func (r *Route) Use(f ...MiddlewareFunc) *Route
- func (r *Route) Validate(ctx *Context) error
Constants ¶
const ( ArgumentTypeBasic = iota ArgumentTypeInt ArgumentTypeFloat ArgumentTypeBool ArgumentTypeEmoji ArgumentTypeUserMention ArgumentTypeChannelMention )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Argument ¶
Argument type contains defined arguments, parsed from the command signature
type Context ¶
type Context struct { Session *discordgo.Session Event *discordgo.MessageCreate Guild *discordgo.Guild Channel *discordgo.Channel User *discordgo.User Prefix string Command string ArgumentString string Arguments []string ArgumentCount int Vars map[string]interface{} // contains filtered or unexported fields }
func ContextFrom ¶
func ContextFrom(session *discordgo.Session, event *discordgo.MessageCreate, r *Route, command string, args []string, argString string) (*Context, error)
Create a new Context from the session and event
func (*Context) BoolArg ¶
Find and return a named bool argument
func (*Context) ChannelArg ¶
Find and return a named Channel argument
func (*Context) ChannelArgType ¶
Find and return a named Channel argument with a specified type
func (*Context) FloatArg ¶
Find and return a named float argument
func (*Context) Get ¶
Get retrieves a variable from the context
func (*Context) IntArg ¶
Find and return a named int argument
func (*Context) Reply ¶
Reply with a user mention
func (*Context) ReplyEmbed ¶
Reply to a user with an embed object
func (*Context) ReplyFile ¶
Reply to a user with a file object
func (*Context) ReplyTo ¶
Reply to a specific user
func (*Context) Replyf ¶
Reply with formatted text
func (*Context) Send ¶
Send text to the originating channel
func (*Context) SendFile ¶
Send a file by name and read from r
func (*Context) Sendf ¶
Send formattable text to the originating channel
func (*Context) Set ¶
Set sets a variable on the context
func (*Context) Usage ¶
Show context usage
type FindOpts ¶ added in v1.1.0
Options for FindComplex. Default is just Args in Find.
type Route ¶
type Route struct { Routes map[string]*Route Name string Usage string Description string Arguments map[string]*Argument ArgumentCount int RequiredArgumentCount int // contains filtered or unexported fields }
Route type contains information about a route, such as middleware, routes, etc
func (*Route) Alias ¶
Add an alias to the parent route for the current route.
func (*Route) Call ¶
Execute a route. Handlers are called synchronously. Sub-routes will be walked until the stack is empty or a match couldn't be found.
func (*Route) FindComplex ¶ added in v1.1.0
Find route by options, including args, case sensitive matching, etc
func (*Route) Group ¶
Create a temporary route to use for registering sub routes. All routes will be copied into this route, with middleware applied.
func (*Route) On ¶
Adds a handler for a specific command. Signature can be a simple command, or a string like the following:
command <arg1> <arg2> [arg3] [#channel] [@user]
The library will automatically parse and validate the required arguments. <> means an argument will be required, [] says it's optional As well as required and optional types, you can use # and @ to signify That routes must match a valid user or channel.
func (*Route) Use ¶
func (r *Route) Use(f ...MiddlewareFunc) *Route
Apply middleware to this route. All sub-routes will also inherit this middleware.