modulepackage
0.0.0-20200517224846-e66453b957c1
Repository: https://github.com/necroforger/dgrouter.git
Documentation: pkg.go.dev
# README
dgrouter
Router to simplify command routing in discord bots. exrouter provides some extra features like wrapping the router type to add command handlers which typecast to its own Context type.
If you make any interesting changes feel free to submit a Pull Request
Features
example
router.On("ping", func(ctx *exrouter.Context) { ctx.Reply("pong")}).Desc("responds with pong")
router.On("avatar", func(ctx *exrouter.Context) {
ctx.Reply(ctx.Msg.Author.AvatarURL("2048"))
}).Desc("returns the user's avatar")
router.Default = router.On("help", func(ctx *exrouter.Context) {
var text = ""
for _, v := range router.Routes {
text += v.Name + " : \t" + v.Description + "\n"
}
ctx.Reply("```" + text + "```")
}).Desc("prints this help menu")
# Functions
New returns a new route.
NewNameMatcher returns a matcher that matches a route's name and aliases.
NewRegexMatcher returns a new regex matcher.