command

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string
	Desc string
	Run  func(ctx *Context)
}

Command is a command to be run and its attribues

type Context

type Context struct {
	ChannelID string
	Args      []string
	Session   *discordgo.Session
}

Context provides context for a command to execute

type Route

type Route struct {
	Prefix string
	Cmd    map[string]*Command
}

Route holds the route for a command based on the prefix.

func NewRoute

func NewRoute(prefix string) *Route

NewRoute generates a Route

func (*Route) CommandHandler

func (r *Route) CommandHandler(msg discordgo.Message, session *discordgo.Session) error

CommandHandler is injected into the CreateMessage event handler to automatically invoke a command.

func (*Route) FindCommand

func (r *Route) FindCommand(name string) (*Command, error)

FindCommand finds if a command exists in a route.

func (*Route) NewCommand

func (r *Route) NewCommand(name string, run func(ctx *Context))

NewCommand adds a command to a route

Jump to

Keyboard shortcuts

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