feat: discord integration

This commit is contained in:
jwinterm
2026-02-01 10:13:57 -05:00
parent b95877ac9c
commit f63bafbc48
2 changed files with 146 additions and 1 deletions
+43
View File
@@ -294,6 +294,49 @@ export async function getClaimableTips(token: string): Promise<{ tips: Claimable
return res.json();
}
// =============================================================================
// Discord OAuth2 Linking
// =============================================================================
export interface DiscordAuthUrlResponse {
auth_url: string;
}
export async function getDiscordAuthUrl(token: string): Promise<DiscordAuthUrlResponse> {
const res = await fetch(`${API_URL}/api/v1/socials/discord/auth-url`, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.error || 'Failed to get Discord auth URL');
}
return res.json();
}
export async function completeDiscordOAuth(
token: string,
code: string,
state: string
): Promise<LinkedSocial> {
const res = await fetch(`${API_URL}/api/v1/socials/discord/callback`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ code, state }),
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.error || 'Failed to link Discord account');
}
return res.json();
}
// =============================================================================
// Username Management
// =============================================================================