Documentation
¶
Index ¶
- Constants
- Variables
- func GetCommandMap() map[string]*Command
- func HandleCommand(usedCommandName string, args []string, command *Command, ...)
- func HandleInteraction(fullID, userID string) *model.ComplexMessage
- func NewErrCannotParseParameter(lang *i18n.Language, err error) error
- func NewErrInvalidValue(lang *i18n.Language, cmd *Command, param *Parameter) error
- func NewErrRequiredParameter(lang *i18n.Language, cmd *Command, param *Parameter) error
- func RegisterCategory(category Category)
- func RegisterCommand(command *Command)
- func RemoveInteractionHandler(baseID string)
- func RunValidation(ctx *Context, validation *Validation) (bool, string)
- type BaseType
- type Category
- type Command
- type Context
- func (ctx *Context) EditComplexMessage(message *model.ComplexMessage) error
- func (ctx *Context) Embed(embed *model.Embed) Result
- func (ctx *Context) Empty() Result
- func (ctx *Context) Error(message string) Result
- func (ctx *Context) ErrorEmbed(embed *model.Embed) Result
- func (ctx *Context) Errorf(format string, args ...any) Result
- func (ctx *Context) RegisterInteractionHandler(baseID string, handler InteractionHandler)
- func (ctx *Context) ReplyRaw(content string) Result
- func (ctx *Context) ReplyWithInteraction(baseID string, message *model.ComplexMessage, handler InteractionHandler) Result
- func (ctx *Context) Success(message string) Result
- func (ctx *Context) SuccessEmbed(embed *model.Embed) Result
- func (ctx *Context) Successf(format string, args ...any) Result
- type Handler
- type InteractionHandler
- type Parameter
- type ParameterType
- type ParameterTypeParser
- type Permission
- type PermissionChecker
- type Result
- type TriggerEvent
- type TriggerType
- type Validation
- type ValidationChecker
Constants ¶
View Source
const ( SuccessEmbedColor = 0x50fa7b ErrorEmbedColor = 0xff5555 PendingEmbedColor = 0x00add8 )
View Source
const (
InteractionBaseIDLength = 10
)
Variables ¶
View Source
var ( ErrRequireParameter = errors.New("required parameter missing") ErrCannotParseArgument = errors.New("cannot parse argument") ErrInvalidValue = errors.New("invalid value") )
View Source
var Prefix string
Functions ¶
func GetCommandMap ¶
func HandleCommand ¶
func HandleCommand( usedCommandName string, args []string, command *Command, bot discord.BotAdapter, trigger *TriggerEvent, )
func HandleInteraction ¶
func HandleInteraction(fullID, userID string) *model.ComplexMessage
func NewErrInvalidValue ¶
func NewErrRequiredParameter ¶
func RegisterCategory ¶
func RegisterCategory(category Category)
func RegisterCommand ¶
func RegisterCommand(command *Command)
func RemoveInteractionHandler ¶
func RemoveInteractionHandler(baseID string)
func RunValidation ¶
func RunValidation(ctx *Context, validation *Validation) (bool, string)
Types ¶
type Command ¶
type Command struct { Validations []*Validation Parameters []*Parameter Aliases []string SubCommands []*Command Name string Handler Handler Permission *Permission Deferred bool Ephemeral bool // contains filtered or unexported fields }
func GetCommand ¶
func GetCommandList ¶
func GetCommandList() []*Command
func (*Command) GetCategory ¶
type Context ¶
type Context struct { Lang *i18n.Language T any RawArgs []string Args []any Bot discord.BotAdapter Channel model.TextChannel MessageID, AuthorID, GuildID string UsedName string Locals map[string]any Command *Command TriggerType TriggerType // contains filtered or unexported fields }
func (*Context) EditComplexMessage ¶
func (ctx *Context) EditComplexMessage(message *model.ComplexMessage) error
func (*Context) RegisterInteractionHandler ¶
func (ctx *Context) RegisterInteractionHandler(baseID string, handler InteractionHandler)
func (*Context) ReplyWithInteraction ¶
func (ctx *Context) ReplyWithInteraction( baseID string, message *model.ComplexMessage, handler InteractionHandler, ) Result
type InteractionHandler ¶
type InteractionHandler func(id, userID, baseID string) (newMessage *model.ComplexMessage, done bool)
type Parameter ¶
type Parameter struct { ValidValues []any Name string Type *ParameterType ValidValuesFunc func() []any Required bool }
func (*Parameter) GetValidValues ¶
type ParameterType ¶
type ParameterType struct { Name string BaseType *BaseType Parser ParameterTypeParser }
type ParameterTypeParser ¶
type Permission ¶
type Permission struct { Name string Checker PermissionChecker }
type PermissionChecker ¶
type Result ¶
type Result struct { Success bool Message *model.ComplexMessage }
type TriggerEvent ¶
type TriggerEvent struct { EventTime time.Time PreferedLanguage i18n.LanguageName Type TriggerType Channel model.TextChannel MessageID, GuildID, AuthorID string DeferResponse func() error Reply func(*Context, *model.ComplexMessage) error Edit func(*Context, *model.ComplexMessage) error }
type TriggerType ¶
type TriggerType string
const ( CommandTriggerSlash TriggerType = "SLASH" CommandTriggerMessage TriggerType = "MESSAGE" )
type Validation ¶
type Validation struct { Name string DependsOn []*Validation Checker ValidationChecker }
type ValidationChecker ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.