This commit is contained in:
unintendedfraud
2023-05-06 12:39:09 +02:00
parent e0ee13f379
commit 9c521af2c7
2 changed files with 13 additions and 3 deletions
+7 -3
View File
@@ -1,6 +1,7 @@
package handlers
import (
"fmt"
"hal/env"
"hal/openai"
"log"
@@ -20,9 +21,12 @@ func OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCreate) {
log.Panicf("failed to query open ai with the following prompt [%s]. Error: %s", m.Content, err.Error())
}
aiResponse := res.Choices[0].Text
if _, err = s.ChannelMessageSend(m.ChannelID, aiResponse); err != nil {
log.Panicf("failed to send the response [%s] to the discord channel [%s]", aiResponse, err.Error())
if len(res.Choices) > 0 {
if _, err = s.ChannelMessageSend(m.ChannelID, aiResponse); err != nil {
log.Panicf("failed to send the response [%s] to the discord channel [%s]", aiResponse, err.Error())
}
} else {
fmt.Println("### no response ##")
}
return