router

package
v0.0.0-...-1520e54 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanBan

func CanBan(s *discordgo.Session, guildID string, m *discordgo.Member) bool

func HasPerm

func HasPerm(userPerms, hasPerm int64) bool

func IsChannelAdmin

func IsChannelAdmin(s *discordgo.Session, channelID, userID string) bool

func WaitForMessage

func WaitForMessage(s *discordgo.Session) chan *discordgo.MessageCreate

func WaitForUserMessage

func WaitForUserMessage(s *discordgo.Session, userID string) chan *discordgo.MessageCreate

func WaitForUserReact

func WaitForUserReact(s *discordgo.Session, userID string) chan *discordgo.MessageReactionAdd

Types

type Context

type Context struct {
	*discordgo.Session
	*discordgo.Message
	Vars   map[interface{}]interface{}
	Prefix string
}

type DefaultPrefixer

type DefaultPrefixer struct {
	// contains filtered or unexported fields
}

func NewDefaultPrefixer

func NewDefaultPrefixer(prefixes ...string) *DefaultPrefixer

func (*DefaultPrefixer) FindPrefix

func (p *DefaultPrefixer) FindPrefix(m *discordgo.Message) (prefix string, ok bool)

func (*DefaultPrefixer) Prefixes

func (p *DefaultPrefixer) Prefixes(*discordgo.Message) []string

type GuildPrefixer

type GuildPrefixer struct {
	// contains filtered or unexported fields
}

func NewGuildPrefixer

func NewGuildPrefixer(prefixes map[string][]string) *GuildPrefixer

func (*GuildPrefixer) FindPrefix

func (p *GuildPrefixer) FindPrefix(m *discordgo.MessageCreate) (prefix string, ok bool)

func (*GuildPrefixer) Prefixes

func (p *GuildPrefixer) Prefixes(m *discordgo.Message) []string

type Middleware

type Middleware func(RouteHandler) RouteHandler

type Parser

type Parser func(string) ([]string, error)

func NewDefaultParser

func NewDefaultParser() Parser

type Prefixer

type Prefixer interface {
	FindPrefix(*discordgo.Message) (prefix string, ok bool) // returns the prefix found and a bool
	Prefixes(*discordgo.Message) []string                   // returns all prefixes available (this is required to display a prefix in the help command)
}

type Route

type Route struct {
	Name        string
	Aliases     []string
	Description string
	Handler     RouteHandler
	Parent      *Route
	Subroutes   []*Route
	Middlewares []Middleware
}

func NewRouter

func NewRouter() *Route

func (*Route) AddMiddlewares

func (r *Route) AddMiddlewares(m ...Middleware) *Route

func (*Route) AddRoutes

func (r *Route) AddRoutes(subroutes ...*Route) *Route

func (*Route) Alias

func (r *Route) Alias(a ...string) *Route

func (*Route) ApplyMiddlewares

func (r *Route) ApplyMiddlewares() RouteHandler

func (*Route) DefaultHelpRouteHandler

func (r *Route) DefaultHelpRouteHandler(ctx *Context, args []string) error

func (*Route) Desc

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

func (*Route) Execute

func (r *Route) Execute(s *discordgo.Session, parser Parser, prefixer Prefixer, m *discordgo.MessageCreate, v map[interface{}]interface{}) error

func (*Route) Find

func (r *Route) Find(name string) *Route

Find finds a route with the given name It will return nil if nothing is found

name : name of route to find

func (*Route) FindFull

func (r *Route) FindFull(args []string) (*Route, int)

FindFull a full path of routes by searching through their subroutes Until the deepest match is found. It will return the route matched and the depth it was found at

args : path of route you wish to find
       ex. FindFull(command, subroute1, subroute2, nonexistent)
       will return the deepest found match, which will be subroute2

func (*Route) On

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

type RouteHandler

type RouteHandler func(*Context, []string) error

func IsAdmin

func IsAdmin(h RouteHandler) RouteHandler

Jump to

Keyboard shortcuts

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