tweaks
This commit is contained in:
@@ -12,6 +12,7 @@ type Config struct {
|
||||
ClientSecret string // ENV DISCORD_CLIENT_SECRET: Discord application client secret (required)
|
||||
OAuthScopes string // Authorisation scopes for OAuth
|
||||
RedirectPath string // ENV DISCORD_REDIRECT_PATH: Path for the OAuth redirect handler (required)
|
||||
BotToken string // ENV DISCORD_BOT_TOKEN: Token for the discord bot (required)
|
||||
}
|
||||
|
||||
func ConfigFromEnv() (any, error) {
|
||||
@@ -20,6 +21,7 @@ func ConfigFromEnv() (any, error) {
|
||||
ClientSecret: env.String("DISCORD_CLIENT_SECRET", ""),
|
||||
OAuthScopes: getOAuthScopes(),
|
||||
RedirectPath: env.String("DISCORD_REDIRECT_PATH", ""),
|
||||
BotToken: env.String("DISCORD_BOT_TOKEN", ""),
|
||||
}
|
||||
|
||||
// Check required fields
|
||||
@@ -32,6 +34,9 @@ func ConfigFromEnv() (any, error) {
|
||||
if cfg.RedirectPath == "" {
|
||||
return nil, errors.New("Envar not set: DISCORD_REDIRECT_PATH")
|
||||
}
|
||||
if cfg.BotToken == "" {
|
||||
return nil, errors.New("Envar not set: DISCORD_BOT_TOKEN")
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user