init DiscordGo

This commit is contained in:
Penguin-71630
2025-12-07 17:17:02 +08:00
parent ec986f2dbf
commit 5c32bb11c9
7 changed files with 176 additions and 391 deletions

35
config/config.go Normal file
View File

@@ -0,0 +1,35 @@
package config
import (
"errors"
"os"
)
type Config struct {
DiscordToken string
APIBaseURL string
BotPrefix string
}
func Load() (*Config, error) {
token := os.Getenv("DISCORD_BOT_TOKEN")
if token == "" {
return nil, errors.New("DISCORD_BOT_TOKEN is required")
}
apiURL := os.Getenv("API_BASE_URL")
if apiURL == "" {
apiURL = "http://localhost:8080" // Default
}
prefix := os.Getenv("BOT_PREFIX")
if prefix == "" {
prefix = "!" // Default prefix
}
return &Config{
DiscordToken: token,
APIBaseURL: apiURL,
BotPrefix: prefix,
}, nil
}