diff --git a/bot/bot.go b/bot/bot.go index 7b6bf94..96b3c2e 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -1,7 +1,6 @@ package bot import ( - "flag" "fmt" "os" "os/signal" @@ -25,6 +24,13 @@ type ( MessageHandler func(s *discordgo.Session, m *discordgo.MessageCreate) ) +func init() { + pflag.Bool("debug", false, "enable debug mode") + pflag.Parse() + + viper.BindPFlags(pflag.CommandLine) +} + func NewBot(s *discordgo.Session, config Config) *Bot { return &Bot{Session: s, Config: config} } @@ -114,11 +120,6 @@ func setupConfig() { C = NewConfig() - flag.Bool("debug", false, "enable debug logging") - pflag.CommandLine.AddGoFlagSet(flag.CommandLine) - pflag.Parse() - viper.BindPFlags(pflag.CommandLine) - viper.SetEnvPrefix("BEEPBOOP") viper.AutomaticEnv()