Documentation ¶
Index ¶
- func IsAuthorNotPermitted(err error) bool
- func IsCommandMessage(composite *MessageComposite) bool
- func IsCommandRun(err error) bool
- func IsInvalidChannel(err error) bool
- func IsNoAccess(err error) bool
- func IsNoPrefixUsed(err error) bool
- func IsNotFound(err error) bool
- func IsPrefixOnly(err error) bool
- func ReceiveMessage(composite *MessageComposite)
- func UnwrapCommandRun(err error) error
- func UsePermission(command Command, permission commons.Permission)
- type Command
- type CommandAccessor
- type CommandDescription
- type CommandFilter
- type CommandFunction
- type CommandMap
- type CommandPrefix
- type CommandRepository
- func (repo *CommandRepository) Commands() []Command
- func (repo *CommandRepository) FilterCommands(filter CommandFilter) []Command
- func (repo *CommandRepository) FindCommandByPrimaryKey(primaryKey string) (Command, error)
- func (repo *CommandRepository) FindCommandsByDesignations(designation string, ignoreCase bool) []Command
- func (repo *CommandRepository) HasCommandWithPrimaryKey(primaryKey string) bool
- func (repo *CommandRepository) RegisterCommand(command Command)
- func (repo *CommandRepository) RegisterCommands(commands ...Command)
- func (repo *CommandRepository) UnregisterCommand(command Command)
- func (repo *CommandRepository) UnregisterCommandWithPrimaryKey(primaryKey string)
- func (repo *CommandRepository) UnregisterCommands(commands ...Command)
- func (repo *CommandRepository) UnregisterCommandsWithPrimaryKeys(primaryKeys ...string)
- type CommandTriggers
- type CommandUsage
- type Configuration
- type Context
- func (ctx *Context) EditEmbedTyping(messageID string, embed *discordgo.MessageEmbed) (*discordgo.Message, error)
- func (ctx *Context) EditMessageTyping(messageID, content string) (*discordgo.Message, error)
- func (ctx *Context) SendEmbedTyping(embed *discordgo.MessageEmbed) (*discordgo.Message, error)
- func (ctx *Context) SendMessageTyping(content string) (*discordgo.Message, error)
- func (ctx *Context) String() (string, error)
- type ErrorHandler
- type MessageComposite
- type PlainCommand
- func (plain *PlainCommand) GetDescription() CommandDescription
- func (plain *PlainCommand) GetPrimaryKey() string
- func (plain *PlainCommand) GetProps() commons.Props
- func (plain *PlainCommand) GetTriggers() *CommandTriggers
- func (plain *PlainCommand) GetUsage() CommandUsage
- func (plain *PlainCommand) IsAccessible(ctx *Context) bool
- func (plain *PlainCommand) IsAuthorPermitted(ctx *Context) bool
- func (plain *PlainCommand) IsChannelValid(ctx *Context) bool
- func (plain *PlainCommand) IsDesignatedBy(designated string, ignoreCase bool) bool
- func (plain *PlainCommand) Run(ctx *Context) error
- type PlainWrapper
- func (plain *PlainWrapper) GeneratePrefixes(ctx *Context) []CommandPrefix
- func (plain *PlainWrapper) GetBotApplication() commons.BotApplication
- func (plain *PlainWrapper) GetConfiguration() *Configuration
- func (plain *PlainWrapper) GetRepository() *CommandRepository
- func (plain *PlainWrapper) HandleError(ctx *Context, err error)
- func (plain *PlainWrapper) HandlePrefixOnly(ctx *Context)
- func (plain *PlainWrapper) StartListening()
- type PrefixGenerator
- type PrefixOnlyHandler
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAuthorNotPermitted ¶
func IsCommandMessage ¶
func IsCommandMessage(composite *MessageComposite) bool
IsCommandMessage returns whether the content of the MessageComposite is valid for the handler.
func IsCommandRun ¶
func IsInvalidChannel ¶
func IsNoAccess ¶
func IsNoPrefixUsed ¶
func IsNotFound ¶
func IsPrefixOnly ¶
func ReceiveMessage ¶
func ReceiveMessage(composite *MessageComposite)
ReceiveMessage processes the MessageComposite within the handler.
func UnwrapCommandRun ¶
func UsePermission ¶
func UsePermission(command Command, permission commons.Permission)
UsePermission defines the permission needed for the user to execute the command,
Types ¶
type Command ¶
type Command interface { GetPrimaryKey() string IsDesignatedBy(designation string, ignoreCase bool) bool GetProps() commons.Props /* Specs */ GetDescription() CommandDescription GetUsage() CommandUsage GetTriggers() *CommandTriggers IsAccessible(ctx *Context) bool IsChannelValid(ctx *Context) bool IsAuthorPermitted(ctx *Context) bool Run(ctx *Context) error }
type CommandAccessor ¶
CommandAccessor is a simple type declaration for a Accessibility-Test-Function. See https://github.com/projectdoll/command-wrapper#CommandAccessor
type CommandDescription ¶
type CommandDescription string
CommandDescription is used to describe a command in more detail. See https://github.com/projectdoll/command-wrapper#CommandDescription
func NoDescription ¶
func NoDescription() CommandDescription
NoDescription returns an empty CommandDescription.
type CommandFilter ¶
type CommandFunction ¶
CommandFunction is a simple type declaration for a Action of an Command. See https://github.com/projectdoll/command-wrapper
type CommandMap ¶
type CommandPrefix ¶
type CommandPrefix string
type CommandRepository ¶
type CommandRepository struct {
Map CommandMap
}
func NewRepository ¶
func NewRepository(cmdMap CommandMap) *CommandRepository
func (*CommandRepository) Commands ¶
func (repo *CommandRepository) Commands() []Command
func (*CommandRepository) FilterCommands ¶
func (repo *CommandRepository) FilterCommands(filter CommandFilter) []Command
func (*CommandRepository) FindCommandByPrimaryKey ¶
func (repo *CommandRepository) FindCommandByPrimaryKey(primaryKey string) (Command, error)
func (*CommandRepository) FindCommandsByDesignations ¶
func (repo *CommandRepository) FindCommandsByDesignations(designation string, ignoreCase bool) []Command
func (*CommandRepository) HasCommandWithPrimaryKey ¶
func (repo *CommandRepository) HasCommandWithPrimaryKey(primaryKey string) bool
func (*CommandRepository) RegisterCommand ¶
func (repo *CommandRepository) RegisterCommand(command Command)
func (*CommandRepository) RegisterCommands ¶
func (repo *CommandRepository) RegisterCommands(commands ...Command)
func (*CommandRepository) UnregisterCommand ¶
func (repo *CommandRepository) UnregisterCommand(command Command)
func (*CommandRepository) UnregisterCommandWithPrimaryKey ¶
func (repo *CommandRepository) UnregisterCommandWithPrimaryKey(primaryKey string)
func (*CommandRepository) UnregisterCommands ¶
func (repo *CommandRepository) UnregisterCommands(commands ...Command)
func (*CommandRepository) UnregisterCommandsWithPrimaryKeys ¶
func (repo *CommandRepository) UnregisterCommandsWithPrimaryKeys(primaryKeys ...string)
type CommandTriggers ¶
type CommandTriggers struct { DM bool `default:"true"` Guild bool `default:"true` Other bool `default:"true` }
CommandTriggers defines the channel types which are accepted during processing.
func NewTriggers ¶
func NewTriggers(dm, guild bool) *CommandTriggers
NewTriggers creates a new CommandTriggers and returns it.
type CommandUsage ¶
type CommandUsage string
CommandUsage is used to represent the argument structure of a command. See https://github.com/projectdoll/command-wrapper#CommandUsage
type Configuration ¶
func NewConfiguration ¶
func NewConfiguration(async, ignoreCase bool) *Configuration
type Context ¶
type Context struct { *MessageComposite `json:"-"` Prefix CommandPrefix `json:"prefix"` PrefixFound bool `json:"prefix_found"` Trim string `json:"trim"` Beheaded string `json:"beheaded"` Cut string `json:"cut"` Label string `json:"label"` Split []string `json:"split"` Args []string `json:"args"` Matches []Command `json:"-"` Match Command `json:"-"` }
func (*Context) EditEmbedTyping ¶
func (*Context) EditMessageTyping ¶
func (*Context) SendEmbedTyping ¶
func (*Context) SendMessageTyping ¶
type ErrorHandler ¶
type MessageComposite ¶
type PlainCommand ¶
type PlainCommand struct { Command Keys []string Props commons.Props Description CommandDescription Usage CommandUsage Triggers *CommandTriggers Accessor CommandAccessor Action CommandFunction }
PlainCommand is a simple command implementation for a command. See: https://github.com/projectdoll/command-wrapper#Command, https://github.com/projectdoll/command-wrapper#create-a-custom-command
func (*PlainCommand) GetDescription ¶
func (plain *PlainCommand) GetDescription() CommandDescription
GetDescription returns the Description of the PlainCommand.
func (*PlainCommand) GetPrimaryKey ¶
func (plain *PlainCommand) GetPrimaryKey() string
GetPrimaryKey returns the first key of PlainCommand.
func (*PlainCommand) GetProps ¶
func (plain *PlainCommand) GetProps() commons.Props
GetProps returns the Props of the PlainCommand.
func (*PlainCommand) GetTriggers ¶
func (plain *PlainCommand) GetTriggers() *CommandTriggers
GetTriggers returns the Triggers of the PlainCommand.
func (*PlainCommand) GetUsage ¶
func (plain *PlainCommand) GetUsage() CommandUsage
GetUsage returns the Usage of the PlainCommand.
func (*PlainCommand) IsAccessible ¶
func (plain *PlainCommand) IsAccessible(ctx *Context) bool
func (*PlainCommand) IsAuthorPermitted ¶
func (plain *PlainCommand) IsAuthorPermitted(ctx *Context) bool
func (*PlainCommand) IsChannelValid ¶
func (plain *PlainCommand) IsChannelValid(ctx *Context) bool
func (*PlainCommand) IsDesignatedBy ¶
func (plain *PlainCommand) IsDesignatedBy(designated string, ignoreCase bool) bool
IsDesignatedBy tests if the Keys of the PlainCommand contains a designation.
func (*PlainCommand) Run ¶
func (plain *PlainCommand) Run(ctx *Context) error
Run executes the command.
type PlainWrapper ¶
type PlainWrapper struct { Wrapper BotApplication commons.BotApplication Repository *CommandRepository Configuration *Configuration PrefixGenerator PrefixGenerator ErrorHandler ErrorHandler PrefixOnlyHandler PrefixOnlyHandler Props commons.Props }
func (*PlainWrapper) GeneratePrefixes ¶
func (plain *PlainWrapper) GeneratePrefixes(ctx *Context) []CommandPrefix
func (*PlainWrapper) GetBotApplication ¶
func (plain *PlainWrapper) GetBotApplication() commons.BotApplication
func (*PlainWrapper) GetConfiguration ¶
func (plain *PlainWrapper) GetConfiguration() *Configuration
func (*PlainWrapper) GetRepository ¶
func (plain *PlainWrapper) GetRepository() *CommandRepository
func (*PlainWrapper) HandleError ¶
func (plain *PlainWrapper) HandleError(ctx *Context, err error)
func (*PlainWrapper) HandlePrefixOnly ¶
func (plain *PlainWrapper) HandlePrefixOnly(ctx *Context)
func (*PlainWrapper) StartListening ¶
func (plain *PlainWrapper) StartListening()
type PrefixGenerator ¶
type PrefixGenerator func(ctx *Context) []CommandPrefix
type PrefixOnlyHandler ¶
type PrefixOnlyHandler func(ctx *Context)
type Wrapper ¶
type Wrapper interface { GetBotApplication() commons.BotApplication GetRepository() *CommandRepository GetConfiguration() *Configuration GeneratePrefixes(ctx *Context) []CommandPrefix HandleError(ctx *Context, err error) HandlePrefixOnly(ctx *Context) StartListening() GetProps() commons.Props }
func NewWrapper ¶
func NewWrapper(botApplication commons.BotApplication, prefixes ...CommandPrefix) Wrapper