mirror of
https://github.com/Penguin-71630/meme-bot-frontend-dc.git
synced 2026-03-12 20:40:16 +08:00
init DiscordGo
This commit is contained in:
35
config/config.go
Normal file
35
config/config.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user