Documentation
¶
Index ¶
- func FillEmptyOpts(opts *Opts)
- type ApplicationError
- type Bot
- type CodeInformation
- type CodeStore
- type CustomCommandHandler
- type ErrorInformation
- type NewUserHandler
- type Opts
- type Payload
- type Repository
- type Server
- type Service
- func (s *Service) AddHandler(handler NewUserHandler)
- func (s *Service) CheckCode(code string) (*CodeInformation, error)
- func (s *Service) CreateUser(discord, xuid string) (*User, error)
- func (s *Service) DeleteUserByDiscord(discord string) error
- func (s *Service) DeleteUserByXUID(xuid string) error
- func (s *Service) GetUserByDiscord(discord string) (*User, error)
- func (s *Service) GetUserByXUID(xuid string) (*User, error)
- func (s *Service) IssueCode(xuid string) (*CodeInformation, error)
- func (s *Service) RevokeCode(code string) error
- type User
- type UserData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillEmptyOpts ¶
func FillEmptyOpts(opts *Opts)
Types ¶
type ApplicationError ¶
type ApplicationError struct {
// ErrorCode should have its 3 first digits represent http status code.
// For example, 50001 will return 500, 40401 will return 404...
ErrorCode int
Message string
}
func NewApplicationError ¶
func NewApplicationError(errorCode int, message string) ApplicationError
func (ApplicationError) Error ¶
func (err ApplicationError) Error() string
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
func (*Bot) RegisterCommands ¶
type CodeInformation ¶
type CodeStore ¶
type CodeStore interface {
GetInformation(code string) (*CodeInformation, error)
GetForXuid(xuid string) (*CodeInformation, error)
Issue(xuid string) (*CodeInformation, error)
Revoke(code string) error
}
type CustomCommandHandler ¶
type CustomCommandHandler func(i *discordgo.InteractionCreate, options map[string]*discordgo.ApplicationCommandInteractionDataOption) string
type ErrorInformation ¶
type NewUserHandler ¶
type NewUserHandler func(user *User)
type Opts ¶
type Opts struct {
Logger *slog.Logger
Repo Repository
CodeStr CodeStore
}
func DefaultOpts ¶
func DefaultOpts() *Opts
type Payload ¶
type Payload struct {
Error *ErrorInformation `json:"error"`
Data interface{} `json:"data"`
}
func FailurePayload ¶
func FailurePayload(err ApplicationError) Payload
func SuccessPayload ¶
func SuccessPayload(data interface{}) Payload
type Repository ¶
type Repository interface {
GetUserByDiscord(discordId string) (*User, error)
GetUserByXUID(xuid string) (*User, error)
CreateUser(discordId, xuid string) (*User, error)
DeleteUserByDiscord(discordId string) error
DeleteUserByXUID(xuid string) error
}
func NewDefaultRepository ¶
func NewDefaultRepository() (Repository, error)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) GetHttpHandler ¶
GetHttpHandler returns http.Handler
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo Repository, codeStr CodeStore) *Service
func (*Service) AddHandler ¶
func (s *Service) AddHandler(handler NewUserHandler)
func (*Service) DeleteUserByDiscord ¶
func (*Service) DeleteUserByXUID ¶
func (*Service) GetUserByDiscord ¶
func (*Service) RevokeCode ¶
Click to show internal directories.
Click to hide internal directories.