fix(discord): automatically add 'Bot' prefix to token if missing (#83)

Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-04-25 16:20:29 +02:00
committed by GitHub
parent 12209ab926
commit 5e3bc0f89b

View File

@@ -30,9 +30,15 @@ func NewDiscord(config map[string]string) *Discord {
duration = 5 * time.Minute duration = 5 * time.Minute
} }
token := config["token"]
if !strings.HasPrefix(token, "Bot ") {
token = "Bot " + token
}
return &Discord{ return &Discord{
conversationTracker: NewConversationTracker[string](duration), conversationTracker: NewConversationTracker[string](duration),
token: config["token"], token: token,
defaultChannel: config["defaultChannel"], defaultChannel: config["defaultChannel"],
} }
} }