fix(commands): '?restart' ohne createMessageCollector Bestätigung per '?restart y'

This commit is contained in:
vibe-bot 2025-08-08 19:35:04 +02:00
parent 250154bfab
commit 916f0ea846

View file

@ -150,20 +150,14 @@ async function handleCommand(message: Message, content: string) {
return; return;
} }
if (cmd === '?restart') { if (cmd === '?restart') {
await reply('Möchten Sie den Bot neu starten? Antworte mit Y oder N innerhalb 30s.'); const confirm = (parts[1] || '').toLowerCase();
const collector = message.channel?.createMessageCollector?.({ filter: (m: any) => m.author?.id === message.author?.id, time: 30_000, max: 1 }); if (confirm === 'y' || confirm === 'yes' || confirm === 'ja' || confirm === 'confirm') {
if (!collector) return; await reply('Neustart wird ausgeführt...');
collector.on('collect', async (m: any) => { try { await fetch('http://127.0.0.1:9001/_restart').catch(() => {}); } catch {}
const v = (m.content || '').trim().toLowerCase(); setTimeout(() => process.exit(0), 500);
if (v === 'y' || v === 'yes' || v === 'ja') { } else {
await reply('Neustart wird ausgeführt...'); await reply('Bitte mit "?restart y" bestätigen.');
try { await fetch('http://127.0.0.1:9001/_restart').catch(() => {}); } catch {} }
// fallback: Prozess beenden; Orchestrator startet neu
setTimeout(() => process.exit(0), 500);
} else {
await reply('Abgebrochen.');
}
});
return; return;
} }
await reply('Unbekannter Command. Nutze ?help.'); await reply('Unbekannter Command. Nutze ?help.');