Enhance Discord authentication and guild management by implementing caching for user and guild data to reduce API calls and improve performance. Update error handling for Discord API responses and refactor the guilds listing logic in the dashboard to streamline data retrieval. Adjust retry logic for rate limits and improve session error handling in the authentication flow.
This commit is contained in:
@@ -323,19 +323,19 @@ class AI (commands .Cog ):
|
||||
import os
|
||||
|
||||
|
||||
db_path =db_path("ai_data.db")
|
||||
if os .path .exists (db_path ):
|
||||
ai_db = db_path("ai_data.db")
|
||||
if os .path .exists (ai_db ):
|
||||
try :
|
||||
|
||||
test_conn =await aiosqlite .connect (db_path )
|
||||
test_conn =await aiosqlite .connect (ai_db )
|
||||
await test_conn .execute ("SELECT name FROM sqlite_master WHERE type='table';")
|
||||
await test_conn .close ()
|
||||
except Exception as e :
|
||||
|
||||
os .remove (db_path )
|
||||
os .remove (ai_db )
|
||||
logger .info ("Removed corrupted AI database, creating new one")
|
||||
|
||||
self .bot .db =await aiosqlite .connect (db_path )
|
||||
self .bot .db =await aiosqlite .connect (ai_db )
|
||||
logger .info ("AI database connection initialized")
|
||||
|
||||
await self .bot .db .execute ("""
|
||||
@@ -401,12 +401,12 @@ class AI (commands .Cog ):
|
||||
import aiosqlite
|
||||
import os
|
||||
|
||||
db_path =db_path("ai_data.db")
|
||||
if not os .path .exists (db_path ):
|
||||
ai_db = db_path("ai_data.db")
|
||||
if not os .path .exists (ai_db ):
|
||||
logger .info ("AI database doesn't exist, will be created on first use")
|
||||
return
|
||||
|
||||
self .bot .db =await aiosqlite .connect (db_path )
|
||||
self .bot .db =await aiosqlite .connect (ai_db )
|
||||
logger .info ("AI database connection initialized for loading")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user