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:
@@ -64,26 +64,11 @@ export default async function GuildsPage() {
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch("https://discord.com/api/users/@me/guilds", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${session.accessToken}`,
|
||||
},
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
userGuilds = await res.json();
|
||||
} else {
|
||||
const body = await res.text().catch(() => "");
|
||||
console.error("Discord guilds fetch failed:", res.status, body);
|
||||
userDiscordError =
|
||||
res.status === 401
|
||||
? "Discord session expired — please sign in again."
|
||||
: "Failed to fetch your Discord servers.";
|
||||
}
|
||||
} catch (err) {
|
||||
const { fetchUserGuilds } = await import("@/lib/guild-auth");
|
||||
userGuilds = await fetchUserGuilds(session.accessToken);
|
||||
} catch (err: any) {
|
||||
console.error("Discord API Error:", err);
|
||||
userDiscordError = "Error connecting to Discord.";
|
||||
userDiscordError = err?.message || "Error connecting to Discord.";
|
||||
}
|
||||
|
||||
const MANAGE_GUILD = BigInt(0x20);
|
||||
|
||||
Reference in New Issue
Block a user