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:
|
if 'welcome_channel_message' not in columns:
|
||||||
cursor.execute('ALTER TABLE server_configs ADD COLUMN welcome_channel_message TEXT')
|
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.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
@ -57,8 +66,19 @@ class Welcome(commands.Cog):
|
||||||
avatar_bytes = await resp.read()
|
avatar_bytes = await resp.read()
|
||||||
|
|
||||||
# Utiliser le fond personnalisé ou celui par défaut
|
# Utiliser le fond personnalisé ou celui par défaut
|
||||||
if banner_background and os.path.exists(banner_background):
|
bg_path = None
|
||||||
background = Image.open(banner_background)
|
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:
|
else:
|
||||||
background = Image.open(os.path.join(base_dir, 'background_template.png'))
|
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:
|
with open(banner_path, 'wb') as f:
|
||||||
f.write(img_data)
|
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.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)
|
@app_commands.checks.has_permissions(administrator=True)
|
||||||
|
|
|
||||||
BIN
config.db
BIN
config.db
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue