bot

package
v0.0.0-...-0673446 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBot

func NewBot(token string, router Router, prefixer Prefixer) *bot

func ReflectArgs

func ReflectArgs(handler Handler, ctx Context, args []string) ([]reflect.Value, error)

func Wait

func Wait()

func WaitForMessage

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

Types

type Category

type Category struct {
	Name     string
	Commands []Command
	Handlers []Handler
}

func (*Category) On

func (c *Category) On(name string, handler CommandHandler) Command

type Command

type Command struct {
	Name        string
	Aliases     []string
	Description string
	Usage       string
	Example     string
	IgnoreCase  bool
	Handler     CommandHandler
}

type CommandHandler

type CommandHandler interface{}

type Context

type Context struct {
	Guild   *discordgo.Guild
	Author  *discordgo.User
	Channel *discordgo.Channel
	Session *discordgo.Session
	Command Command
}

func (*Context) Reply

func (ctx *Context) Reply(r string)

type Handler

type Handler interface{}

type Parser

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

func DefaultParser

func DefaultParser() Parser

type Prefixer

type Prefixer func(*discordgo.Message) (string, bool)

func DefaultPrefixer

func DefaultPrefixer(prefixes ...string) Prefixer

func GuildPrefixer

func GuildPrefixer(guildPrefixes map[string][]string) Prefixer

type Router

type Router struct {
	Parser   Parser
	Commands []Command
}

func NewRouter

func NewRouter(parser Parser) Router

func (*Router) AddCommand

func (r *Router) AddCommand(c Command)

func (*Router) FindCommand

func (r *Router) FindCommand(name string) (bool, *Command)

func (*Router) On

func (r *Router) On(name string, handler CommandHandler) Command

func (*Router) RouteCommand

func (r *Router) RouteCommand(s *discordgo.Session, m *discordgo.Message, content string)

Jump to

Keyboard shortcuts

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