dbots/services/bot/input.go

34 lines
895 B
Go

package bot
import (
"net/http"
"strconv"
"git.elisiei.xyz/elisiei/dbots/internal/db"
"git.elisiei.xyz/elisiei/dbots/internal/errorutil"
)
type CreateBotRequest struct {
ID string `json:"id"`
Overview string `json:"overview"`
Description string `json:"description"`
IsSlash bool `json:"is_slash"`
InstallContext db.InstallContext `json:"install_context"`
Prefix *string `json:"prefix"`
ImportedFrom *string `json:"imported_from"`
CoOwners []string `json:"co_owners"`
}
func (c *CreateBotRequest) Bind(req *http.Request) error {
if _, err := strconv.ParseUint(c.ID, 10, 64); err != nil {
return errorutil.ErrInvalidID
}
if len(c.Overview) < 15 || len(c.Overview) > 50 {
return errorutil.ErrInvalidOverview
}
// todo: proper checks idk
return nil
}