From 930d86920a012005cdb09b56b765e07431a1d5c4 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Fri, 12 Jan 2024 15:54:33 +0000 Subject: [PATCH] Check for threads' existence properly --- src/cogs/ollama.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cogs/ollama.py b/src/cogs/ollama.py index 58c0087..63b87eb 100644 --- a/src/cogs/ollama.py +++ b/src/cogs/ollama.py @@ -124,7 +124,7 @@ class ChatHistory: def get_thread(self, thread: str) -> dict[str, list[dict[str, str]] | discord.Member | int]: """Gets a copy of an entire thread""" - return self._internal[thread].copy() + return self._internal.get(thread, {}).copy() SERVER_KEYS = list(CONFIG["ollama"].keys()) @@ -223,7 +223,7 @@ class Ollama(commands.Cog): ] ): if context is not None: - if context not in self.contexts: + if not self.history.get_thread(context): await ctx.respond("Invalid context key.") return await ctx.defer()