command

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicContext

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

BasicContext is a basic context implementation.

func NewBasicContext

func NewBasicContext(args []string, message *discordgo.MessageCreate, session *discordgo.Session, m *Map, g *Group) *BasicContext

NewBasicContext creates a new basic context and returns it.

func (BasicContext) Arguments

func (b BasicContext) Arguments() []string

Arguments ...

func (BasicContext) Author

func (b BasicContext) Author() *discordgo.User

Author ...

func (BasicContext) Channel

func (b BasicContext) Channel() *discordgo.Channel

Channel ...

func (BasicContext) Group

func (b BasicContext) Group() *Group

func (BasicContext) Guild

func (b BasicContext) Guild() *discordgo.Guild

Guild ...

func (BasicContext) Map

func (b BasicContext) Map() *Map

func (BasicContext) Message

func (b BasicContext) Message() *discordgo.MessageCreate

Message ...

type BasicGroup

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

BasicGroup is a basic group implementation.

func NewBasicGroup

func NewBasicGroup(name string, description string) *BasicGroup

NewBasicGroup initializes a new basic group.

func (*BasicGroup) AddCommand

func (c *BasicGroup) AddCommand(cmd Command)

AddCommand ...

func (*BasicGroup) AddCommands

func (c *BasicGroup) AddCommands(commands []Command)

AddCommands adds a list of commands.

func (*BasicGroup) CanExecute

func (c *BasicGroup) CanExecute(name string) bool

CanExecute ...

func (*BasicGroup) Command

func (c *BasicGroup) Command(name string) Command

Command ...

func (*BasicGroup) Commands

func (c *BasicGroup) Commands() map[string]Command

Commands ...

func (*BasicGroup) Description

func (c *BasicGroup) Description() string

Description ...

func (*BasicGroup) Execute

func (c *BasicGroup) Execute(name string, ctx Context, session *discordgo.Session) error

Execute ...

func (*BasicGroup) Name

func (c *BasicGroup) Name() string

Name ...

type Command

type Command interface {
	// Execute is called when a command is attempted.
	Execute(context Context, session *discordgo.Session) error
	// Name returns the given name of the command
	Name() string
	// Description returns the description of the command
	Description() string
}

Command is the simple command interface for commands.

type Context

type Context interface {
	// Arguments ...
	Arguments() []string
	// Author ...
	Author() *discordgo.User
	// Channel ...
	Channel() *discordgo.Channel
	// Guild ...
	Guild() *discordgo.Guild
	// Message ...
	Message() *discordgo.MessageCreate
	// Map ...
	Map() *Map
	// Group ...
	Group() *Group
}

Context is a context for a command execute attempt. It contains the necessary information to execute a command.

type Group

type Group interface {
	// Name returns the command group's name.
	Name() string
	// Description returns a description about this group
	Description() string
	// AddCommand adds a command with the passed name and command.
	AddCommand(name string, command Command)
	// Command returns a command by its name.
	Command(name string) Command
	// Commands returns the command map index.
	Commands() map[string]Command
	// CanExecute returns true if the command name passed can be executed.
	CanExecute(name string) bool
	// Execute executes a command by its name, context, and session.
	Execute(name string, ctx Context, session *discordgo.Session) error
}

Group is a command group used for implementing sub-categories for commands.

type Map

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

Map is an implementation of a command map.

func NewCommandMap

func NewCommandMap() *Map

NewCommandMap returns a new implementation of a command map.

func (*Map) CanExecute

func (m *Map) CanExecute(name string) bool

CanExecute returns true if a command can be executed by the name passed.

func (*Map) CanRegisterCommand

func (m *Map) CanRegisterCommand(cmd Command) bool

CanRegisterCommand returns true if a command can be registered under the name passed.

func (*Map) CanRegisterGroup

func (m *Map) CanRegisterGroup(group Group) bool

CanRegisterGroup returns true if a group can be registered under the name passed.

func (*Map) Commands

func (m *Map) Commands() map[string]Command

Commands returns all commands in the command map.

func (*Map) Execute

func (m *Map) Execute(command string, ctx Context, session *discordgo.Session) error

Execute executes a command on the command map using the parameters passed.

func (*Map) GetAllCommandNames

func (m *Map) GetAllCommandNames() []string

func (*Map) Group

func (m *Map) Group(name string) Group

Group returns a command map group by its name.

func (*Map) GroupExists

func (m *Map) GroupExists(name string) bool

GroupExists returns true if the group passed exists.

func (*Map) GroupedCommands

func (m *Map) GroupedCommands() map[string]Command

GroupedCommands returns all grouped commands in the command map.

func (*Map) Groups

func (m *Map) Groups() map[string]Group

Groups returns the command map's groups.

func (*Map) RegisterCommand

func (m *Map) RegisterCommand(command Command, override bool)

RegisterCommand registers a command to the command map using the information passed.

func (*Map) RegisterCommands added in v0.1.2

func (m *Map) RegisterCommands(commands []Command, overide bool)

func (*Map) RegisterGroup added in v0.1.2

func (m *Map) RegisterGroup(group Group)

RegisterGroup registers a command group by its name to the command map.

func (*Map) RegisterGroups added in v0.1.2

func (m *Map) RegisterGroups(groups []Group)

Jump to

Keyboard shortcuts

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