Documentation
¶
Index ¶
- type BasicContext
- func (b BasicContext) Arguments() []string
- func (b BasicContext) Author() *discordgo.User
- func (b BasicContext) Channel() *discordgo.Channel
- func (b BasicContext) Group() *Group
- func (b BasicContext) Guild() *discordgo.Guild
- func (b BasicContext) Map() *Map
- func (b BasicContext) Message() *discordgo.MessageCreate
- type BasicGroup
- func (c *BasicGroup) AddCommand(cmd Command)
- func (c *BasicGroup) AddCommands(commands []Command)
- func (c *BasicGroup) CanExecute(name string) bool
- func (c *BasicGroup) Command(name string) Command
- func (c *BasicGroup) Commands() map[string]Command
- func (c *BasicGroup) Description() string
- func (c *BasicGroup) Execute(name string, ctx Context, session *discordgo.Session) error
- func (c *BasicGroup) Name() string
- type Command
- type Context
- type Group
- type Map
- func (m *Map) CanExecute(name string) bool
- func (m *Map) CanRegisterCommand(cmd Command) bool
- func (m *Map) CanRegisterGroup(group Group) bool
- func (m *Map) Commands() map[string]Command
- func (m *Map) Execute(command string, ctx Context, session *discordgo.Session) error
- func (m *Map) GetAllCommandNames() []string
- func (m *Map) Group(name string) Group
- func (m *Map) GroupExists(name string) bool
- func (m *Map) GroupedCommands() map[string]Command
- func (m *Map) Groups() map[string]Group
- func (m *Map) RegisterCommand(command Command, override bool)
- func (m *Map) RegisterCommands(commands []Command, overide bool)
- func (m *Map) RegisterGroup(group Group)
- func (m *Map) RegisterGroups(groups []Group)
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) Group ¶
func (b BasicContext) Group() *Group
func (BasicContext) Map ¶
func (b BasicContext) Map() *Map
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) AddCommands ¶
func (c *BasicGroup) AddCommands(commands []Command)
AddCommands adds a list of commands.
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 ¶
CanExecute returns true if a command can be executed by the name passed.
func (*Map) CanRegisterCommand ¶
CanRegisterCommand returns true if a command can be registered under the name passed.
func (*Map) CanRegisterGroup ¶
CanRegisterGroup returns true if a group can be registered under the name passed.
func (*Map) GetAllCommandNames ¶
func (*Map) GroupExists ¶
GroupExists returns true if the group passed exists.
func (*Map) GroupedCommands ¶
GroupedCommands returns all grouped commands in the command map.
func (*Map) RegisterCommand ¶
RegisterCommand registers a command to the command map using the information passed.
func (*Map) RegisterCommands ¶ added in v0.1.2
func (*Map) RegisterGroup ¶ added in v0.1.2
RegisterGroup registers a command group by its name to the command map.