const conversationLogMap = new Map();
let content = message.content;
let authorId = message.author.id
if (message.content.includes(`<@${client.user.id}>`)) {
let slice = content.replace(`<@${client.user.id}>`, "");
content = slice;
}
const backstory = `${guildSettings.backstory.replace(
`{BotName}`,
client.user.username
)}`;
let conversationLog = conversationLogMap.get(authorId);
if (!conversationLogMap.has(authorId)) {
conversationLogMap.set(authorId, backstory);
conversationLog = conversationLogMap.get(authorId)
}
conversationLog += `\nUser: ${content}`;
console.log(conversationLog)
const answer = (await getResponse(conversationLog)) || "No Comment.";
conversationLog += `\n Bot: ${answer}\n`;
console.log(conversationLog);
full code : https://sourceb.in/8qbAqPYjXu