dgcommand

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

README

dgcommand

command parsing and handling with discordgo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	HandlerMeta
	Callback HandlerFunc
	parsing.CommandDefinition
}

func NewCommand

func NewCommand(definition string, callback HandlerFunc) *Command

func (*Command) Handle

func (cmd *Command) Handle(ctx CommandContext)

func (*Command) Use

func (cmd *Command) Use(middleware ...MiddlewareFunc) *Command

type CommandContext

type CommandContext struct {
	context.Context
	Session *discordgo.Session
	Message *discordgo.MessageCreate
	OnError func(ctx CommandContext, err error) error
	// contains filtered or unexported fields
}

func (*CommandContext) Args

func (ctx *CommandContext) Args() []string

func (*CommandContext) Error

func (ctx *CommandContext) Error(err error)

func (*CommandContext) Reply

func (ctx *CommandContext) Reply(msg string)

context object for discordgo

func (*CommandContext) SendEmbed

func (ctx *CommandContext) SendEmbed(e *embed.Embed)

func (*CommandContext) SendFile

func (ctx *CommandContext) SendFile(name string, r io.Reader)

func (*CommandContext) SetArgs

func (ctx *CommandContext) SetArgs(args []string)

func (*CommandContext) WithValue

func (ctx *CommandContext) WithValue(k, v interface{})

type CommandGroup

type CommandGroup struct {
	HandlerMeta
	Commands       map[string]Handler
	DefaultHandler Handler
}

func Group

func Group() *CommandGroup

func (*CommandGroup) AddHandler

func (h *CommandGroup) AddHandler(name string, handler Handler)

func (*CommandGroup) Command

func (r *CommandGroup) Command(definition string, f HandlerFunc) *Command

func (*CommandGroup) Default

func (r *CommandGroup) Default(h Handler)

func (*CommandGroup) Handle

func (h *CommandGroup) Handle(ctx CommandContext)

func (*CommandGroup) On

func (r *CommandGroup) On(name string, f HandlerFunc)

type Handler

type Handler interface {
	Handle(ctx CommandContext)
}

type HandlerFunc

type HandlerFunc func(ctx CommandContext)

func OnPrefix

func OnPrefix(prefix string, next Handler) HandlerFunc

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(ctx CommandContext)

type HandlerMeta

type HandlerMeta struct {
	Description string
	DisplayName string
}

func (*HandlerMeta) Desc

func (h *HandlerMeta) Desc(text string)

func (*HandlerMeta) Display

func (h *HandlerMeta) Display(text string)

func (*HandlerMeta) Metadata

func (h *HandlerMeta) Metadata() *HandlerMeta

type MiddlewareFunc

type MiddlewareFunc func(h HandlerFunc) HandlerFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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