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.
This commit is contained in:
@@ -25,10 +25,11 @@ import os
|
||||
import aiohttp
|
||||
from utils.cv2 import CV2
|
||||
|
||||
db_folder = 'db'
|
||||
from utils.db_paths import db_path as resolve_db_path
|
||||
|
||||
db_file = 'giveaways.db'
|
||||
db_path = os.path.join(db_folder, db_file)
|
||||
connection = sqlite3.connect(db_path)
|
||||
giveaways_db_path = resolve_db_path(db_file)
|
||||
connection = sqlite3.connect(giveaways_db_path)
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
@@ -74,7 +75,7 @@ class Giveaway(commands.Cog):
|
||||
self.bot = bot
|
||||
|
||||
async def cog_load(self) -> None:
|
||||
self.connection = await aiosqlite.connect(db_path)
|
||||
self.connection = await aiosqlite.connect(giveaways_db_path)
|
||||
self.cursor = await self.connection.cursor()
|
||||
await self.check_for_ended_giveaways()
|
||||
self.GiveawayEnd.start()
|
||||
|
||||
Reference in New Issue
Block a user