Maintenance de Kuby
This commit is contained in:
parent
997b897b28
commit
b5cb907283
2 changed files with 23 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue