modified: bot.py

This commit is contained in:
SimolZimol
2025-08-20 18:11:56 +02:00
parent 1b97d9b933
commit 8d650c0252

38
bot.py
View File

@@ -298,7 +298,7 @@ def load_user_data_from_mysql(user_id, guild_id):
"nickname": result[12],
"ai_ban": int(result[15]) if len(result) > 15 and result[15] is not None else 0,
"mutes": int(result[16]) if len(result) > 16 and result[16] is not None else 0,
"warns": int(result[17]) if len(result) > 17 and result[17] is not None else 0
"warns": 0 # Will be calculated from user_warnings table
}
else:
user_data = {
@@ -319,39 +319,17 @@ def load_user_data_from_mysql(user_id, guild_id):
"mutes": 0,
"warns": 0
}
insert_user_data(
user_data["user_id"],
user_data["guild_id"],
user_data["permission"],
user_data["points"],
user_data["ban"],
user_data["askmultus"],
user_data["filter_value"],
user_data["chat_history"],
user_data["xp"],
user_data["level"],
user_data["nickname"]
)
# Count warnings from user_warnings table
warning_count_query = "SELECT COUNT(*) FROM user_warnings WHERE user_id = %s AND guild_id = %s"
cursor.execute(warning_count_query, (user_id, guild_id))
warning_count = cursor.fetchone()[0]
user_data["warns"] = warning_count
return user_data
except Exception as e:
logger.error(f"Error loading user data from MySQL: {e}")
# Return default user data in case of error
return {
"user_id": user_id,
"guild_id": guild_id,
"permission": 0,
"points": 0,
"ban": 0,
"askmultus": 0,
"filter_value": 0,
"rank": 0,
"chat_history": [],
"asknotes_history": [],
"xp": 0,
"level": 1,
"nickname": ""
}
return None
finally:
if cursor:
cursor.close()