Refactor database path resolution in cogs and improve cog loading error handling. Update database connections in Giveaway, Nightmode, and Owner cogs to use a centralized path resolver. Enhance cog loading feedback with success and failure messages.
Some checks failed
CI / Bot (Python) (push) Successful in 12s
CI / Dashboard (Next.js) (push) Failing after 9s

This commit is contained in:
TheOnlyMace
2026-07-21 22:28:18 +02:00
parent 9006b06c09
commit 18ef29f777
6 changed files with 114 additions and 44 deletions

View File

@@ -12,7 +12,7 @@
# ╚══════════════════════════════════════════════════════════════════╝
from __future__ import annotations
from utils.db_paths import db_path
from utils.db_paths import db_path as resolve_db_path
from discord.ext import commands
from discord import *
from PIL import Image, ImageDraw, ImageFont, ImageFilter
@@ -71,12 +71,12 @@ BACK_COMPAT_BADGE_DICT = DISCORD_BADGE_EMOJIS
db_folder = 'db'
db_file = 'badges.db'
db_path = os.path.join(db_folder, db_file)
badges_db_path = resolve_db_path(db_file)
FONT_PATH = os.path.join('utils', 'arial.ttf')
# --- Database Setup ---
os.makedirs(db_folder, exist_ok=True)
conn = sqlite3.connect(db_path)
os.makedirs(os.path.dirname(badges_db_path) or 'db', exist_ok=True)
conn = sqlite3.connect(badges_db_path)
c = conn.cursor()
c.execute('CREATE TABLE IF NOT EXISTS badges (user_id INTEGER PRIMARY KEY)')
@@ -136,7 +136,7 @@ class Owner(commands.Cog):
self.client = client
self.staff = set()
self.np_cache = []
self.db_path = db_path('np.db')
self.db_path = resolve_db_path('np.db')
self.stop_tour = False
self.bot_owner_ids = BOT_OWNER_IDS
self.client.loop.create_task(self.setup_database())