From 84529ca96652534803d15a2886eeb17d673a59f8 Mon Sep 17 00:00:00 2001 From: unintendedfraud Date: Mon, 25 Mar 2024 01:34:57 +0100 Subject: [PATCH] remove panics --- env/main.go | 4 ---- handlers/message_created.go | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/env/main.go b/env/main.go index 7c5371c..8d2eb94 100644 --- a/env/main.go +++ b/env/main.go @@ -19,8 +19,6 @@ func GetEnvVariables() Env { AppID: tempest.StringToSnowflake(os.Getenv("HAL_APP_ID")), PublicKey: os.Getenv("HAL_PUBLIC_KEY"), Token: os.Getenv("HAL_TOKEN"), - Port: os.Getenv("PORT"), - Addr: os.Getenv("ADDR"), ServerIDs: serverIDs, OpenaiHalToken: os.Getenv("OPENAI_HAL"), } @@ -30,8 +28,6 @@ type Env struct { AppID tempest.Snowflake PublicKey string Token string - Port string - Addr string ServerIDs []tempest.Snowflake OpenaiHalToken string } diff --git a/handlers/message_created.go b/handlers/message_created.go index 2706850..1bb646c 100644 --- a/handlers/message_created.go +++ b/handlers/message_created.go @@ -41,7 +41,8 @@ func (h Handler) OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCrea fmt.Sprintf("X_X: %s", err.Error()), ) - log.Panicf("failed to query open ai with the following prompt [%s]. Error: %s", m.Content, err.Error()) + log.Printf("\nfailed to query open ai with the following prompt [%s]. Error: %s", m.Content, err.Error()) + return } if len(res.Choices) > 0 { @@ -76,7 +77,7 @@ func cleanMessage(p string) string { func sendResponse(s *discordgo.Session, channelID string, response string) { if _, err := s.ChannelMessageSend(channelID, response); err != nil { - log.Panicf("failed to send the response [%s] to the discord channel [%s]", response, err.Error()) + log.Printf("\nfailed to send the response [%s] to the discord channel [%s]", response, err.Error()) } }