package config

import (
	"fmt"
	"os"

	"github.com/joho/godotenv"
)

type Config struct {
	BotToken string
	AppID    string
	GuildID  string
	DBHost   string
}

func LoadConfig() (*Config, error) {
	if err := godotenv.Load(); err != nil {
		return nil, err
	}

	token := os.Getenv("BOT_TOKEN")
	if token == "" {
		return nil, fmt.Errorf("BOT_TOKEN is not set")
	}

	appID := os.Getenv("APP_ID")
	if appID == "" {
		return nil, fmt.Errorf("APP_ID is not set")
	}

	guildID := os.Getenv("GUILD_ID")
	if guildID == "" {
		return nil, fmt.Errorf("GUILD_ID is not set")
	}

	dbHost := os.Getenv("DB_HOST")
	if dbHost == "" {
		return nil, fmt.Errorf("DB_HOST is not set")
	}

	return &Config{
		BotToken: token,
		AppID:    appID,
		GuildID:  guildID,
		DBHost:   dbHost,
	}, nil
}
