From 890744574b57de9e1e307afde3a0aaecea04e12c Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 9 Nov 2025 23:43:44 +0000 Subject: [PATCH] Prettier format pending files --- api/discord/token.ts | 35 ++++++++++++--------- client/contexts/DiscordActivityContext.tsx | 36 ++++++++++++++++------ server/index.ts | 15 ++++++--- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/api/discord/token.ts b/api/discord/token.ts index 794226c0..36830afc 100644 --- a/api/discord/token.ts +++ b/api/discord/token.ts @@ -1,6 +1,7 @@ import { createClient } from "@supabase/supabase-js"; -const supabaseUrl = process.env.VITE_SUPABASE_URL || "https://kmdeisowhtsalsekkzqd.supabase.co"; +const supabaseUrl = + process.env.VITE_SUPABASE_URL || "https://kmdeisowhtsalsekkzqd.supabase.co"; const supabaseServiceRole = process.env.SUPABASE_SERVICE_ROLE || ""; export default async function handler(req: any, res: any) { @@ -25,19 +26,22 @@ export default async function handler(req: any, res: any) { } // Exchange authorization code for access token - const tokenResponse = await fetch("https://discord.com/api/v10/oauth2/token", { - method: "POST", - headers: { - "Content-Type": "application/x-www-form-urlencoded", + const tokenResponse = await fetch( + "https://discord.com/api/v10/oauth2/token", + { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: new URLSearchParams({ + client_id: clientId, + client_secret: clientSecret, + grant_type: "authorization_code", + code, + redirect_uri: "https://127.0.0.1", // Placeholder for Activity + }).toString(), }, - body: new URLSearchParams({ - client_id: clientId, - client_secret: clientSecret, - grant_type: "authorization_code", - code, - redirect_uri: "https://127.0.0.1", // Placeholder for Activity - }).toString(), - }); + ); if (!tokenResponse.ok) { const error = await tokenResponse.json(); @@ -69,7 +73,10 @@ export default async function handler(req: any, res: any) { } const discordUser = await userResponse.json(); - console.log("[Discord Token] Token exchange successful for user:", discordUser.id); + console.log( + "[Discord Token] Token exchange successful for user:", + discordUser.id, + ); // Return access token to Activity return res.status(200).json({ diff --git a/client/contexts/DiscordActivityContext.tsx b/client/contexts/DiscordActivityContext.tsx index 96d9c8a4..538ff39f 100644 --- a/client/contexts/DiscordActivityContext.tsx +++ b/client/contexts/DiscordActivityContext.tsx @@ -116,7 +116,9 @@ export const DiscordActivityProvider: React.FC< prompt: "none", }); - console.log("[Discord Activity] Got authorization code, exchanging for token..."); + console.log( + "[Discord Activity] Got authorization code, exchanging for token...", + ); // Exchange code for access token via our backend const tokenResponse = await fetch("/api/discord/token", { @@ -130,7 +132,10 @@ export const DiscordActivityProvider: React.FC< if (!tokenResponse.ok) { const errorData = await tokenResponse.json(); const errMsg = errorData.error || "Failed to exchange code"; - console.error("[Discord Activity] Token exchange failed:", errMsg); + console.error( + "[Discord Activity] Token exchange failed:", + errMsg, + ); setError(errMsg); setIsLoading(false); return; @@ -139,7 +144,9 @@ export const DiscordActivityProvider: React.FC< const tokenData = await tokenResponse.json(); const access_token = tokenData.access_token; - console.log("[Discord Activity] Got access token, authenticating with SDK..."); + console.log( + "[Discord Activity] Got access token, authenticating with SDK...", + ); // Authenticate with SDK using the access token const authResult = await sdk.commands.authenticate({ @@ -153,15 +160,20 @@ export const DiscordActivityProvider: React.FC< return; } - console.log("[Discord Activity] Authenticated with SDK, fetching user profile..."); + console.log( + "[Discord Activity] Authenticated with SDK, fetching user profile...", + ); setAuth(authResult); // Get user info using the access token - const userResponse = await fetch("https://discord.com/api/v10/users/@me", { - headers: { - Authorization: `Bearer ${access_token}`, + const userResponse = await fetch( + "https://discord.com/api/v10/users/@me", + { + headers: { + Authorization: `Bearer ${access_token}`, + }, }, - }); + ); if (!userResponse.ok) { console.error("[Discord Activity] Failed to fetch user profile"); @@ -171,13 +183,17 @@ export const DiscordActivityProvider: React.FC< } const discordUserData = await userResponse.json(); - console.log("[Discord Activity] User profile fetched:", discordUserData.username); + console.log( + "[Discord Activity] User profile fetched:", + discordUserData.username, + ); // Store the user data const userData: DiscordUser = { id: discordUserData.id, discord_id: discordUserData.id, - full_name: discordUserData.global_name || discordUserData.username, + full_name: + discordUserData.global_name || discordUserData.username, username: discordUserData.username, avatar_url: discordUserData.avatar ? `https://cdn.discordapp.com/avatars/${discordUserData.id}/${discordUserData.avatar}.png` diff --git a/server/index.ts b/server/index.ts index da2f2807..45c71d0a 100644 --- a/server/index.ts +++ b/server/index.ts @@ -943,15 +943,20 @@ export function createServer() { if (!accessToken) { console.error("[Discord Token] No access token in response"); - return res.status(500).json({ error: "Failed to obtain access token" }); + return res + .status(500) + .json({ error: "Failed to obtain access token" }); } // Fetch Discord user info to ensure token is valid - const userResponse = await fetch("https://discord.com/api/v10/users/@me", { - headers: { - Authorization: `Bearer ${accessToken}`, + const userResponse = await fetch( + "https://discord.com/api/v10/users/@me", + { + headers: { + Authorization: `Bearer ${accessToken}`, + }, }, - }); + ); if (!userResponse.ok) { console.error("[Discord Token] Failed to fetch user info");