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.
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:33:30 +02:00
parent 60390009d1
commit f15c869993
6 changed files with 131 additions and 73 deletions

View File

@@ -14,7 +14,7 @@ from utils.db_paths import db_path, jsondb_path
from fastapi import APIRouter, Depends, HTTPException, Request
from api.dependencies import get_bot, limiter
from api.discord_auth import require_discord_session, get_manageable_guild_ids
from api.discord_auth import get_manageable_guild_ids, get_discord_headers
from api.db_manager import db_manager
from api.schemas import (
GuildSummary, GuildDetails, PrefixConfig, AutomodConfig,
@@ -46,8 +46,11 @@ router = APIRouter()
async def list_guilds(request: Request, bot: "Axiom" = Depends(get_bot)):
"""
Lists guilds the bot is in, filtered to those the caller can manage on Discord.
Session is already verified by middleware — only fetch manageable guild IDs here.
"""
token, _ = await require_discord_session(request)
token, _ = get_discord_headers(request)
if not token:
raise HTTPException(status_code=403, detail="X-Discord-Access-Token header is required.")
manageable_ids = await get_manageable_guild_ids(token)
guilds_list = []