Files
dislate/lib/command.go

39 lines
646 B
Go
Raw Normal View History

2024-11-21 21:24:46 -03:00
package bot
import (
"errors"
"github.com/bwmarrin/discordgo"
)
2024-11-21 21:24:46 -03:00
type Command interface {
ApplicationCommand() *discordgo.ApplicationCommand
Validate() error
2024-11-21 21:24:46 -03:00
}
type Handler[CTX any] interface {
Handle(ctx CTX) error
}
type HandlerFunc[CTX any] func(ctx CTX) error
func (h HandlerFunc[CTX]) Handle(ctx CTX) error {
return h(ctx)
2024-11-21 21:24:46 -03:00
}
type Ctx struct {
discordgo.Interaction
}
2024-11-21 21:24:46 -03:00
type ChatCommandCtx struct {
Ctx
Options ChatCommandCtxOptions
2024-11-21 21:24:46 -03:00
}
var (
ErrChatCommandOptionNotExists = errors.New("chat command option does not exist")
ErrChatCommandOptionInvalidType = errors.New("chat command option is not of the type requested")
)