modified: bot.py
This commit is contained in:
16
bot.py
16
bot.py
@@ -172,7 +172,7 @@ def insert_user_data(user_id, guild_id, permission, points, ban, askmultus, filt
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
"""
|
||||
serialized_chat_history = json.dumps(chat_history)
|
||||
data = (user_id, guild_id, permission, points, ban, askmultus, filter_value, 0, serialized_chat_history, 0, 1) # Initialisiere XP auf 0 und Level auf 1
|
||||
data = (user_id, guild_id, permission, points, ban, askmultus, filter_value, 0, serialized_chat_history, 0, 1) # XP auf 0 und Level auf 1 setzen
|
||||
try:
|
||||
db_cursor.execute(insert_query, data)
|
||||
db_connection.commit()
|
||||
@@ -181,7 +181,6 @@ def insert_user_data(user_id, guild_id, permission, points, ban, askmultus, filt
|
||||
print(f"Error inserting user data: {e}")
|
||||
db_connection.rollback()
|
||||
|
||||
|
||||
def update_user_data(user_id, guild_id, field, value):
|
||||
global db_connection, db_cursor # global-Deklaration muss vor dem Zugriff erfolgen
|
||||
try:
|
||||
@@ -233,7 +232,6 @@ def load_user_data_from_mysql(user_id, guild_id):
|
||||
close_database_connection(connection)
|
||||
|
||||
if result:
|
||||
# Wenn das Level und die XP nicht vorhanden sind, initialisieren
|
||||
user_data = {
|
||||
"user_id": result[0],
|
||||
"guild_id": result[1],
|
||||
@@ -249,7 +247,7 @@ def load_user_data_from_mysql(user_id, guild_id):
|
||||
"level": result[11]
|
||||
}
|
||||
else:
|
||||
# Falls keine Benutzerdaten gefunden werden, initialisiere sie neu
|
||||
# Falls keine Benutzerdaten gefunden werden, initialisiere sie neu und füge sie in die DB ein
|
||||
user_data = {
|
||||
"user_id": user_id,
|
||||
"guild_id": guild_id,
|
||||
@@ -260,11 +258,12 @@ def load_user_data_from_mysql(user_id, guild_id):
|
||||
"filter_value": 0, # Standardwert für Filter
|
||||
"rank": 0, # Standardrang
|
||||
"chat_history": [], # Leerer Chatverlauf
|
||||
"asknotes_history": [], # Leerer Chatverlauf
|
||||
"asknotes_history": [], # Leerer Notizverlauf
|
||||
"xp": 0, # Standard-XP
|
||||
"level": 1 # Standardlevel
|
||||
"level": 1 # Start-Level
|
||||
}
|
||||
|
||||
# Initialisiere die Benutzerdaten in der Datenbank
|
||||
insert_user_data(
|
||||
user_data["user_id"],
|
||||
user_data["guild_id"],
|
||||
@@ -273,10 +272,7 @@ def load_user_data_from_mysql(user_id, guild_id):
|
||||
user_data["ban"],
|
||||
user_data["askmultus"],
|
||||
user_data["filter_value"],
|
||||
user_data["chat_history"],
|
||||
user_data["asknotes_history"],
|
||||
user_data["xp"],
|
||||
user_data["level"]
|
||||
user_data["chat_history"]
|
||||
)
|
||||
|
||||
return user_data
|
||||
|
||||
Reference in New Issue
Block a user