toOpenAIMessages: Add fallback to use user id on empty resolved name

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.
This commit is contained in:
Wroclaw 2023-09-27 20:45:23 +02:00
parent ffa79e798e
commit b7f6a5fe91

View file

@ -88,7 +88,8 @@ function getAuthorUsername(message: DiscordMessage): string | undefined {
if (name.length >= 3) return name; if (name.length >= 3) return name;
} }
const name = formatName(message.author.username); const name = formatName(message.author.username);
return name; if (name.length > 0) return name;
return message.author.id;
} }
/** /**