Fix typing indicator going away on longer prompts

This commit is contained in:
Christopher Cookman 2023-03-08 17:52:31 -07:00
parent 3743c8a486
commit 3b4168aa98
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -84,7 +84,9 @@ client.on('messageCreate', async (message) => {
message.channel.send(lang.timeout) message.channel.send(lang.timeout)
}, config.openai.resetTime); }, config.openai.resetTime);
} }
message.channel.sendTyping(); var typing = setInterval(() => {
message.channel.sendTyping();
}, 1000)
// Add the message to the session // Add the message to the session
sessions[message.channelId].messages.push({ sessions[message.channelId].messages.push({
"name": "User", "name": "User",
@ -101,6 +103,7 @@ client.on('messageCreate', async (message) => {
// Add the bot's response to the session // Add the bot's response to the session
sessions[message.channelId].messages.push(output); sessions[message.channelId].messages.push(output);
// Send the bot's response // Send the bot's response
clearInterval(typing);
message.channel.send(output.content); message.channel.send(output.content);
}); });
}); });