refactor(makeprompt.py): remove unused code and simplify try-except block

This commit is contained in:
Paillat
2023-05-05 13:35:19 +02:00
parent 380165fa07
commit 788827ab48

View File

@@ -57,14 +57,6 @@ def get_guild_data(message):
""" """
guild_data = {} guild_data = {}
guid = mg_to_guid(message) guid = mg_to_guid(message)
try:
curs_premium.execute(
"SELECT * FROM data WHERE guild_id = ?", (guid,)
) # get the data of the guild
except Exception as e:
raise e
pass
try: try:
curs_data.execute( curs_data.execute(
"SELECT * FROM model WHERE guild_id = ?", (guid,) "SELECT * FROM model WHERE guild_id = ?", (guid,)
@@ -73,15 +65,15 @@ def get_guild_data(message):
model = data[1] model = data[1]
except: except:
model = "gpt-3.5-turbo" model = "gpt-3.5-turbo"
try: try:
# [2] # get the premium status of the guild curs_premium.execute(
data = curs_premium.fetchone() "SELECT * FROM data WHERE guild_id = ?", (guid,)
premium = data[2] ) # get the data of the guild
premium = curs_premium.fetchone()[2]
except Exception as e: except Exception as e:
premium = 0
raise e raise e
premium = 0 # if the guild is not in the database, it's not premium pass
try: try:
curs_data.execute( curs_data.execute(
"SELECT * FROM images WHERE guild_id = ?", (mg_to_guid(message),) "SELECT * FROM images WHERE guild_id = ?", (mg_to_guid(message),)