From b5cb9072839d04b6557f59d6dc677149afe67e92 Mon Sep 17 00:00:00 2001 From: Mathis Date: Fri, 20 Feb 2026 13:44:07 +0100 Subject: [PATCH] Maintenance de Kuby --- commandes/welcome.py | 26 +++++++++++++++++++++++--- config.db | Bin 8192 -> 8192 bytes 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/commandes/welcome.py b/commandes/welcome.py index c94945e..a0078c2 100644 --- a/commandes/welcome.py +++ b/commandes/welcome.py @@ -44,6 +44,15 @@ class Welcome(commands.Cog): if 'welcome_channel_message' not in columns: cursor.execute('ALTER TABLE server_configs ADD COLUMN welcome_channel_message TEXT') + # Migration: Conversion des chemins absolus en chemins relatifs pour les bannières + cursor.execute("SELECT server_id, welcome_banner_background FROM server_configs WHERE welcome_banner_background IS NOT NULL") + for server_id, path in cursor.fetchall(): + if path and os.path.isabs(path): + filename = os.path.basename(path) + # Vérifier si c'est bien une bannière dans le dossier banners + if "banner_" in filename: + cursor.execute("UPDATE server_configs SET welcome_banner_background = ? WHERE server_id = ?", (filename, server_id)) + conn.commit() conn.close() @@ -57,8 +66,19 @@ class Welcome(commands.Cog): avatar_bytes = await resp.read() # Utiliser le fond personnalisé ou celui par défaut - if banner_background and os.path.exists(banner_background): - background = Image.open(banner_background) + bg_path = None + if banner_background: + # Si c'est un chemin absolu (pour compatibilité temporaire) + if os.path.isabs(banner_background) and os.path.exists(banner_background): + bg_path = banner_background + else: + # Sinon on cherche dans le dossier banners/ + potential_path = os.path.join(base_dir, "banners", banner_background) + if os.path.exists(potential_path): + bg_path = potential_path + + if bg_path: + background = Image.open(bg_path) else: background = Image.open(os.path.join(base_dir, 'background_template.png')) @@ -187,7 +207,7 @@ class Welcome(commands.Cog): with open(banner_path, 'wb') as f: f.write(img_data) - return banner_path + return os.path.basename(banner_path) @app_commands.command(name="setwelcome", description="Définit le salon, les messages de bienvenue et le fond de la bannière") @app_commands.checks.has_permissions(administrator=True) diff --git a/config.db b/config.db index 48bf53bf8bccad6b0a2cf50ebf2bc0364910323f..ab8fdf64f0fec75983008373a06d8a81537387a6 100644 GIT binary patch delta 58 zcmV-A0LA}+K!8Ay8vzZG976#Ov0$bT1XKVIRI?Ef`VNtRP!oY6iNL|R+^T?(c?$pr Q20vS)B(C?!2?AVL~Mj0~?#8B12>3 zrb91p9BD!-7N3`