PiZzA
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m23s

This commit is contained in:
2026-01-27 13:52:57 -07:00
parent 9694a42f3f
commit 221c5cec97
9 changed files with 348 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ import (
type Config struct {
// Discord settings
DiscordToken string
AdminIDs []string
// Himbucks settings
HimbucksPerReward int
@@ -36,6 +37,8 @@ type Config struct {
HimbucksCooldown int
HimboardCooldown int
SendbucksCooldown int
ShopCooldown int
GivebucksCooldown int
}
var AppConfig *Config
@@ -45,6 +48,7 @@ func LoadConfig() *Config {
config := &Config{
// Discord settings
DiscordToken: getEnv("DISCORD_TOKEN", ""),
AdminIDs: getEnvSlice("ADMIN_USER_IDS", []string{}),
// Himbucks settings
HimbucksPerReward: getEnvInt("HIMBUCKS_PER_REWARD", 10),
@@ -71,6 +75,8 @@ func LoadConfig() *Config {
HimbucksCooldown: getEnvInt("HIMBUCKS_COOLDOWN_SECONDS", 5),
HimboardCooldown: getEnvInt("HIMBOARD_COOLDOWN_SECONDS", 5),
SendbucksCooldown: getEnvInt("SENDBUCKS_COOLDOWN_SECONDS", 1800),
ShopCooldown: getEnvInt("SHOP_COOLDOWN_SECONDS", 5),
GivebucksCooldown: getEnvInt("GIVEBUCKS_COOLDOWN_SECONDS", 1),
}
AppConfig = config
@@ -93,4 +99,29 @@ func getEnvInt(key string, defaultValue int) int {
}
}
return defaultValue
}
}
func getEnvSlice(key string, defaultValue []string) []string {
if value := os.Getenv(key); value != "" {
return importStrings(value)
}
return defaultValue
}
func importStrings(s string) []string {
var strings []string
current := ""
for _, c := range s {
if c == ',' {
strings = append(strings, current)
current = ""
} else {
current += string(c)
}
}
if current != "" {
strings = append(strings, current)
}
return strings
}