package bot

import (
	"net/http"
	"strconv"

	"codeberg.org/nextgo/dbots/internal/db"
	"codeberg.org/nextgo/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
}
