From ae64bc9fa2ce4107580697f309162bd3e4854d98 Mon Sep 17 00:00:00 2001 From: Rene Teigen Date: Thu, 5 Jan 2023 22:29:48 +0000 Subject: [PATCH] Fixed opener_file not being able to be used alone --- cogs/gpt_3_commands_and_converser.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cogs/gpt_3_commands_and_converser.py b/cogs/gpt_3_commands_and_converser.py index bfe0b4e..fa18e41 100644 --- a/cogs/gpt_3_commands_and_converser.py +++ b/cogs/gpt_3_commands_and_converser.py @@ -795,19 +795,23 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): await self.deletion_queue(message) return - if not opener or not opener_file: + if not opener and not opener_file: user_id_normalized = user.id else: user_id_normalized = ctx.author.id - # Pre-check for opener, check if they provided a valid file if it is indeed a file. - # If the opener ends in .txt, its a file and we want to load it - if opener_file.endswith(".txt"): - # Load the file and read it into opener - opener_file = f"openers{separator}{opener_file}" - opener_file = await self.load_file(opener_file, ctx) - opener = opener_file + opener - if not opener_file: - return + if opener_file: # only load in files if it's included in the command, if not pass on as normal + if opener_file.endswith(".txt"): + # Load the file and read it into opener + opener_file = f"openers{separator}{opener_file}" + opener_file = await self.load_file(opener_file, ctx) + if not opener: # if we only use opener_file then only pass on opener_file for the opening prompt + opener = opener_file + else: + opener = opener_file + opener + if not opener_file: + return + else: + pass self.conversating_users[user_id_normalized] = User(user_id_normalized)