Nightly: Partymode serverseitig Start/Stop Endpunkte + Panic stoppt global; Frontend triggert Party-Start/Stop

This commit is contained in:
vibe-bot 2025-08-09 22:43:13 +02:00
parent 442c42ef23
commit 9bb402edd3
3 changed files with 107 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import ReactDOM from 'react-dom';
import { fetchChannels, fetchSounds, playSound, setVolumeLive, getVolume, adminStatus, adminLogin, adminLogout, adminDelete, adminRename, playUrl, fetchCategories, createCategory, assignCategories, assignBadges, clearBadges, updateCategory, deleteCategory } from './api';
import { fetchChannels, fetchSounds, playSound, setVolumeLive, getVolume, adminStatus, adminLogin, adminLogout, adminDelete, adminRename, playUrl, fetchCategories, createCategory, assignCategories, assignBadges, clearBadges, updateCategory, deleteCategory, partyStart, partyStop } from './api';
import type { VoiceChannelInfo, Sound, Category } from './types';
import { getCookie, setCookie } from './cookies';
@ -243,9 +243,13 @@ export default function App() {
if (chaosMode) {
setChaosMode(false);
await stopChaosMode();
// serverseitig stoppen
if (selected) { const [guildId] = selected.split(':'); try { await partyStop(guildId); } catch {} }
} else {
setChaosMode(true);
await startChaosMode();
// serverseitig starten
if (selected) { const [guildId, channelId] = selected.split(':'); try { await partyStart(guildId, channelId); } catch {} }
}
};
@ -310,7 +314,7 @@ export default function App() {
>
Partymode
</button>
<button className="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-6 rounded-lg transition duration-300" onClick={async () => { setChaosMode(false); await stopChaosMode(); }}>Panic</button>
<button className="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-6 rounded-lg transition duration-300" onClick={async () => { setChaosMode(false); await stopChaosMode(); if(selected){ const [guildId]=selected.split(':'); try{ await partyStop(guildId);}catch{} } }}>Panic</button>
</div>
</div>
</header>

View file

@ -90,6 +90,22 @@ export async function playSound(soundName: string, guildId: string, channelId: s
}
}
export async function partyStart(guildId: string, channelId: string) {
const res = await fetch(`${API_BASE}/party/start`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ guildId, channelId })
});
if (!res.ok) throw new Error('Partymode Start fehlgeschlagen');
}
export async function partyStop(guildId: string) {
const res = await fetch(`${API_BASE}/party/stop`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ guildId })
});
if (!res.ok) throw new Error('Partymode Stop fehlgeschlagen');
}
export async function setVolumeLive(guildId: string, volume: number): Promise<void> {
const res = await fetch(`${API_BASE}/volume`, {
method: 'POST',