modified: bot.py
This commit is contained in:
30
bot.py
30
bot.py
@@ -475,7 +475,7 @@ async def update_all_users(batch_size=20, pause_duration=1):
|
|||||||
|
|
||||||
for member in batch:
|
for member in batch:
|
||||||
user_id = member.id
|
user_id = member.id
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
# Daten aktualisieren
|
# Daten aktualisieren
|
||||||
nickname = member.display_name
|
nickname = member.display_name
|
||||||
@@ -858,7 +858,7 @@ async def check_giveaway(giveaway_id):
|
|||||||
logger.info(f"Processing {len(winners)} winners for giveaway '{giveaway.title}'")
|
logger.info(f"Processing {len(winners)} winners for giveaway '{giveaway.title}'")
|
||||||
for i, winner in enumerate(winners):
|
for i, winner in enumerate(winners):
|
||||||
try:
|
try:
|
||||||
user_data = load_user_data(winner.id, giveaway.guild_id)
|
user_data = load_user_data_sync(winner.id, giveaway.guild_id)
|
||||||
# Verwende die bereits beim Erstellen generierte UUID
|
# Verwende die bereits beim Erstellen generierte UUID
|
||||||
winner_uuid = giveaway.winner_uuids[i] # i-te UUID für i-ten Gewinner
|
winner_uuid = giveaway.winner_uuids[i] # i-te UUID für i-ten Gewinner
|
||||||
logger.info(f"Assigning winner {i+1}/{len(winners)}: {winner.name} (ID: {winner.id}) to existing UUID: {winner_uuid}")
|
logger.info(f"Assigning winner {i+1}/{len(winners)}: {winner.name} (ID: {winner.id}) to existing UUID: {winner_uuid}")
|
||||||
@@ -1012,7 +1012,7 @@ async def level(ctx, user: discord.User = None):
|
|||||||
user_id = user.id
|
user_id = user.id
|
||||||
|
|
||||||
# Lade die Benutzerdaten (XP und Level) aus der Datenbank
|
# Lade die Benutzerdaten (XP und Level) aus der Datenbank
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
# Berechne die für das nächste Level benötigten XP
|
# Berechne die für das nächste Level benötigten XP
|
||||||
current_level = user_data["level"]
|
current_level = user_data["level"]
|
||||||
@@ -1164,7 +1164,7 @@ async def points(ctx):
|
|||||||
user_id = ctx.author.id
|
user_id = ctx.author.id
|
||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
# Lade Benutzerdaten aus der MySQL-Datenbank
|
# Lade Benutzerdaten aus der MySQL-Datenbank
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
points = user_data["points"]
|
points = user_data["points"]
|
||||||
|
|
||||||
@@ -1182,7 +1182,7 @@ async def permissionlevel(ctx):
|
|||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
|
|
||||||
# Load user data from the MySQL database
|
# Load user data from the MySQL database
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
permission_level = user_data["permission"]
|
permission_level = user_data["permission"]
|
||||||
rank = ""
|
rank = ""
|
||||||
@@ -1205,13 +1205,13 @@ async def permissionlevel(ctx):
|
|||||||
@client.hybrid_command()
|
@client.hybrid_command()
|
||||||
async def addpoints(ctx, user: discord.User, amount: int):
|
async def addpoints(ctx, user: discord.User, amount: int):
|
||||||
"""Adds a certain number of points to a user."""
|
"""Adds a certain number of points to a user."""
|
||||||
user_perms = load_user_data(ctx.author.id, ctx.guild.id)
|
user_perms = load_user_data_sync(ctx.author.id, ctx.guild.id)
|
||||||
if 5 <= user_perms["permission"]:
|
if 5 <= user_perms["permission"]:
|
||||||
user_id = user.id
|
user_id = user.id
|
||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
|
|
||||||
# Lade Benutzerdaten aus der MySQL-Datenbank
|
# Lade Benutzerdaten aus der MySQL-Datenbank
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
# Füge die Punkte hinzu
|
# Füge die Punkte hinzu
|
||||||
user_data["points"] += amount
|
user_data["points"] += amount
|
||||||
@@ -1231,13 +1231,13 @@ async def addpoints(ctx, user: discord.User, amount: int):
|
|||||||
@client.hybrid_command()
|
@client.hybrid_command()
|
||||||
async def resetpoints(ctx, user: discord.User):
|
async def resetpoints(ctx, user: discord.User):
|
||||||
"""Resets a user's points to 0."""
|
"""Resets a user's points to 0."""
|
||||||
user_perms = load_user_data(ctx.author.id, ctx.guild.id)
|
user_perms = load_user_data_sync(ctx.author.id, ctx.guild.id)
|
||||||
if 5 <= user_perms["permission"]:
|
if 5 <= user_perms["permission"]:
|
||||||
user_id = user.id
|
user_id = user.id
|
||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
|
|
||||||
# Lade Benutzerdaten aus der MySQL-Datenbank
|
# Lade Benutzerdaten aus der MySQL-Datenbank
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
# Setze die Punkte auf 0 zurück
|
# Setze die Punkte auf 0 zurück
|
||||||
user_data["points"] = 0
|
user_data["points"] = 0
|
||||||
@@ -1256,7 +1256,7 @@ async def resetpoints(ctx, user: discord.User):
|
|||||||
|
|
||||||
@client.hybrid_command()
|
@client.hybrid_command()
|
||||||
async def shutdown_(ctx):
|
async def shutdown_(ctx):
|
||||||
user_perms = load_user_data(ctx.author.id, ctx.guild.id)
|
user_perms = load_user_data_sync(ctx.author.id, ctx.guild.id)
|
||||||
if 8 <= user_perms["permission"]:
|
if 8 <= user_perms["permission"]:
|
||||||
await ctx.send("Shutting down the bot...")
|
await ctx.send("Shutting down the bot...")
|
||||||
await client.logout()
|
await client.logout()
|
||||||
@@ -1267,7 +1267,7 @@ async def shutdown_(ctx):
|
|||||||
@client.hybrid_command()
|
@client.hybrid_command()
|
||||||
async def owner_command(ctx):
|
async def owner_command(ctx):
|
||||||
try:
|
try:
|
||||||
user_perms = load_user_data(ctx.author.id, ctx.guild.id)
|
user_perms = load_user_data_sync(ctx.author.id, ctx.guild.id)
|
||||||
if 10 <= user_perms["permission"]:
|
if 10 <= user_perms["permission"]:
|
||||||
await client.tree.sync()
|
await client.tree.sync()
|
||||||
await ctx.send("reloaded !")
|
await ctx.send("reloaded !")
|
||||||
@@ -1287,7 +1287,7 @@ async def askmultus(ctx, *, prompt: str):
|
|||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
|
|
||||||
# Lade Benutzerdaten aus der MySQL-Datenbank
|
# Lade Benutzerdaten aus der MySQL-Datenbank
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
if user_data["points"] >= 5:
|
if user_data["points"] >= 5:
|
||||||
user_data["points"] -= 5
|
user_data["points"] -= 5
|
||||||
@@ -1322,7 +1322,7 @@ async def process_ai_queue():
|
|||||||
ctx, user_id, user_name, prompt, channel_id, full_data, user_history_field, model = await askmultus_queue.get()
|
ctx, user_id, user_name, prompt, channel_id, full_data, user_history_field, model = await askmultus_queue.get()
|
||||||
|
|
||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_history = user_data.get(user_history_field, [])
|
user_history = user_data.get(user_history_field, [])
|
||||||
@@ -1445,7 +1445,7 @@ async def addbackgrounddata(ctx, *, data: str):
|
|||||||
async def summarize(ctx, number: int):
|
async def summarize(ctx, number: int):
|
||||||
"""Summarizes the last x messages in the chat."""
|
"""Summarizes the last x messages in the chat."""
|
||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
user_perms = load_user_data(ctx.author.id, guild_id)
|
user_perms = load_user_data_sync(ctx.author.id, guild_id)
|
||||||
if 5 < user_perms["permission"]:
|
if 5 < user_perms["permission"]:
|
||||||
try:
|
try:
|
||||||
# Fetch the last 10 messages in the channel
|
# Fetch the last 10 messages in the channel
|
||||||
@@ -1508,7 +1508,7 @@ async def toggle_feature(ctx, feature: str, state: str):
|
|||||||
"""Allows admin to enable or disable features."""
|
"""Allows admin to enable or disable features."""
|
||||||
guild_id = ctx.guild.id
|
guild_id = ctx.guild.id
|
||||||
user_id = ctx.author.id
|
user_id = ctx.author.id
|
||||||
user_data = load_user_data(user_id, guild_id)
|
user_data = load_user_data_sync(user_id, guild_id)
|
||||||
user_perms = user_data["permission"]
|
user_perms = user_data["permission"]
|
||||||
|
|
||||||
if user_perms < 8: # Nur Admins (permission level >= 8) können Funktionen aktivieren/deaktivieren
|
if user_perms < 8: # Nur Admins (permission level >= 8) können Funktionen aktivieren/deaktivieren
|
||||||
|
|||||||
Reference in New Issue
Block a user