clean: initial commit ohne Secrets

This commit is contained in:
vibe-bot 2025-08-07 23:24:56 +02:00
commit c39f5fce0c
20 changed files with 782 additions and 0 deletions

34
web/src/api.ts Normal file
View file

@ -0,0 +1,34 @@
import type { Sound, VoiceChannelInfo } from './types';
const API_BASE = import.meta.env.VITE_API_BASE_URL || '/api';
export async function fetchSounds(q?: string): Promise<Sound[]> {
const url = new URL(`${API_BASE}/sounds`, window.location.origin);
if (q) url.searchParams.set('q', q);
const res = await fetch(url.toString());
if (!res.ok) throw new Error('Fehler beim Laden der Sounds');
return res.json();
}
export async function fetchChannels(): Promise<VoiceChannelInfo[]> {
const res = await fetch(`${API_BASE}/channels`);
if (!res.ok) throw new Error('Fehler beim Laden der Channels');
return res.json();
}
export async function playSound(soundName: string, guildId: string, channelId: string): Promise<void> {
const res = await fetch(`${API_BASE}/play`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ soundName, guildId, channelId })
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data?.error || 'Play fehlgeschlagen');
}
}