From b7f6a5fe91fb4cdffe3018e1913e8d8aa9e7d4ca Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Wed, 27 Sep 2023 20:45:23 +0200 Subject: [PATCH] toOpenAIMessages: Add fallback to use user id on empty resolved name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously if someone named whose current mechanism resolved to empty string ("Джо" for example) then the openai would scream that the name does not match their server side regex. Meaning that the bot could not be used in a given channel until that person changes it's display name or it will be forgotten for the bot. --- src/toOpenAIMessages.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/toOpenAIMessages.ts b/src/toOpenAIMessages.ts index 3ee9ee8..f93d235 100644 --- a/src/toOpenAIMessages.ts +++ b/src/toOpenAIMessages.ts @@ -88,7 +88,8 @@ function getAuthorUsername(message: DiscordMessage): string | undefined { if (name.length >= 3) return name; } const name = formatName(message.author.username); - return name; + if (name.length > 0) return name; + return message.author.id; } /**