From 6c4f8166b0b7ff072e00543e2a809a5a36ef6a57 Mon Sep 17 00:00:00 2001 From: Paillat Date: Mon, 6 Mar 2023 23:16:32 +0100 Subject: [PATCH] Update makeprompt.py --- code/makeprompt.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/code/makeprompt.py b/code/makeprompt.py index ddf6d78..0695196 100644 --- a/code/makeprompt.py +++ b/code/makeprompt.py @@ -33,7 +33,8 @@ async def chat_process(self, message): tts = data[11] pretend_to_be = data[12] pretend_enabled = data[13] - + try: cp.execute("SELECT * FROM data WHERE guild_id = ?", (message.guild.id,)) + except: pass try: c.execute("SELECT * FROM model WHERE guild_id = ?", (message.guild.id,)) # get the model in the database model = c.fetchone()[1] @@ -42,15 +43,17 @@ async def chat_process(self, message): try: premium = cp.fetchone()[2] # get the premium status of the guild except: premium = 0 # if the guild is not in the database, it's not premium - channels = [] # create the channels list + channels = [] try: - cp.execute("SELECT * FROM channels WHERE guild_id = ?", (message.guild.id,)) # get the channels in the premium database - if premium: channels = cp.fetchone()[1:] # if the guild is premium, add the channels to the channels list - debug("Premium channels: "+str(channels)) - except: - debug("Error while getting premium channels") - channels = [] # if the guild is not premium, the channels list is empty + cp.execute("SELECT * FROM channels WHERE guild_id = ?", (message.guild.id,)) + if premium: + #for 5 times, we get c.fetchone()[1] to c.fetchone()[5] and we add it to the channels list, each time with try except + for i in range(5): + #we use the i variable to get the channel id + try: channels.append(str(cp.fetchone()[i+1])) + except: pass + except: channels = [] if api_key is None: return # if the api key is not set, return