Files
velox-bot/internal/config/config.go
T
FernandoJVideira 461f8435c0 feat: add Docker support and bot configuration
- Introduced Dockerfile for building the bot application using Go.
- Added .dockerignore to exclude unnecessary files from the Docker context.
- Updated docker-compose.yml to define the bot service and its dependencies, including environment variables for database and Lavalink configuration.
- Modified internal configuration to streamline environment variable handling.
2026-03-18 13:39:31 +00:00

60 lines
1.1 KiB
Go

package config
import (
"fmt"
"os"
"github.com/joho/godotenv"
)
type Config struct {
BotToken string
AppID string
GuildID string
DBHost string
LavalinkHost string
LavalinkPass string
TwitchClientID 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")
dbHost := os.Getenv("DB_HOST")
if dbHost == "" {
return nil, fmt.Errorf("DB_HOST is not set")
}
lavalinkHost := os.Getenv("LAVALINK_HOST")
lavalinkPass := os.Getenv("LAVALINK_PASSWORD")
twitchClientID := os.Getenv("TWITCH_CLIENT_ID")
if twitchClientID == "" {
return nil, fmt.Errorf("TWITCH_CLIENT_ID is not set")
}
return &Config{
BotToken: token,
AppID: appID,
GuildID: guildID,
DBHost: dbHost,
LavalinkHost: lavalinkHost,
LavalinkPass: lavalinkPass,
TwitchClientID: twitchClientID,
}, nil
}