fix(commands): '?restart' ohne createMessageCollector Bestätigung per '?restart y'
This commit is contained in:
parent
250154bfab
commit
916f0ea846
1 changed files with 8 additions and 14 deletions
|
|
@ -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;
|
|
||||||
collector.on('collect', async (m: any) => {
|
|
||||||
const v = (m.content || '').trim().toLowerCase();
|
|
||||||
if (v === 'y' || v === 'yes' || v === 'ja') {
|
|
||||||
await reply('Neustart wird ausgeführt...');
|
await reply('Neustart wird ausgeführt...');
|
||||||
try { await fetch('http://127.0.0.1:9001/_restart').catch(() => {}); } catch {}
|
try { await fetch('http://127.0.0.1:9001/_restart').catch(() => {}); } catch {}
|
||||||
// fallback: Prozess beenden; Orchestrator startet neu
|
|
||||||
setTimeout(() => process.exit(0), 500);
|
setTimeout(() => process.exit(0), 500);
|
||||||
} else {
|
} else {
|
||||||
await reply('Abgebrochen.');
|
await reply('Bitte mit "?restart y" bestätigen.');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await reply('Unbekannter Command. Nutze ?help.');
|
await reply('Unbekannter Command. Nutze ?help.');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue