#conversationLogMap is not differentiating with ``message.author.id``

12 messages · Page 1 of 1 (latest)

pulsar bloom
#
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

vital sageBOT
#
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
vale perch
#

Are you making the map in the listener?

pulsar bloom
timber musk
#

Then you make a new empty one on every message received. So it won‘t contain anything when you check

pulsar bloom
timber musk
#

Well, what I said is what your code currently does. Not what you intend it to do

pulsar bloom
timber musk
#

Define your map outside of the function, but seeing your full code you already do that

timber musk