router

package
v0.0.0-...-4a205d6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapHandler

func WrapHandler(fn HandlerFunc) dgrouter.HandlerFunc

WrapHandler wraps a HandlerFunc into a dgrouter.HandlerFunc

func WrapMiddleware

func WrapMiddleware(mfn MiddlewareFunc) dgrouter.MiddlewareFunc

WrapMiddleware wraps a MiddlewareFunc into a dgrouter.MiddlewareFunc

Types

type Args

type Args []string

Args is the command arguments

func ParseArgs

func ParseArgs(content string) Args

ParseArgs ...

func (Args) After

func (a Args) After(n int) string

After returns the combined arguments after N

func (Args) Get

func (a Args) Get(n int) string

Get gets it Nth argument

type Context

type Context struct {
	Route *dgrouter.Route
	Msg   *discordgo.Message
	Ses   *discordgo.Session

	Args Args

	Vars *sync.Map
}

Context ...

func NewContext

func NewContext(s *discordgo.Session, m *discordgo.Message, args Args, route *dgrouter.Route) *Context

NewContext returns a new context from a message

func (*Context) Channel

func (c *Context) Channel(channelID string) (*discordgo.Channel, error)

Channel retrieves a channel from the state or restapi

func (*Context) Get

func (c *Context) Get(key string) (interface{}, bool)

Get gets a value from the Vars map

func (*Context) Guild

func (c *Context) Guild(guildID string) (*discordgo.Guild, error)

Guild retrieves a guild from the state or restapi

func (*Context) Member

func (c *Context) Member(guildID, userID string) (*discordgo.Member, error)

Member retrieves a member from the state or restapi

func (*Context) Reply

func (c *Context) Reply(args ...interface{})

Reply sends a normal message to the channel the parent message was sent in

func (*Context) ReplyEmbed

func (c *Context) ReplyEmbed(e *discordgo.MessageEmbed)

ReplyEmbed same as Reply but sends and Embed

func (*Context) ReplyEmbedQuick

func (c *Context) ReplyEmbedQuick(args ...interface{})

ReplyEmbedQuick same as ReplyEmbed but has only the Description property

func (*Context) Set

func (c *Context) Set(key string, v interface{})

Set stores a value in the Vars map

type HandlerFunc

type HandlerFunc func(*Context)

HandlerFunc ...

func UnwrapHandler

func UnwrapHandler(fn dgrouter.HandlerFunc) HandlerFunc

UnwrapHandler unwraps a dgrouter.HandlerFunc into a HandlerFunc

type MiddlewareFunc

type MiddlewareFunc func(HandlerFunc) HandlerFunc

MiddlewareFunc ...

type Route

type Route struct {
	*dgrouter.Route
}

Route router wrapper

func NewRoute

func NewRoute() *Route

NewRoute ...

func (*Route) Desc

func (r *Route) Desc(desc string) *Route

Desc sets the description of the route

func (*Route) FindAndExecute

func (r *Route) FindAndExecute(s *discordgo.Session, prefix string, botID string, m *discordgo.Message) error

FindAndExecute finds the closest command and executes the callback

func (*Route) Group

func (r *Route) Group(fn func(rt *Route)) *Route

Group groups multiple routes together

func (*Route) On

func (r *Route) On(name string, handler HandlerFunc) *Route

On matches a Route with a name

func (*Route) Use

func (r *Route) Use(mfn ...MiddlewareFunc) *Route

Use specifes what MiddlewareFuncs a Route should have

Jump to

Keyboard shortcuts

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