smysluplnější chytání chyby u ordinace

This commit is contained in:
Histmy 2025-05-13 16:15:07 +03:00
parent 8892f99ff2
commit b0c0c2344b
Signed by: Histmy
GPG Key ID: AC2E43C463D8F329

View File

@ -89,7 +89,7 @@ async function executeOrdinaceFlow() {
}
const handleMessageAndGetNazev = (socket: WebSocket) => new Promise<string | void>((res, rej) => {
const handleMessageAndGetNazev = (socket: WebSocket) => new Promise<string>((res, rej) => {
const listener = (m: RawData) => {
//const mes = m.toString();
//logg("data:", mes);
@ -122,6 +122,10 @@ const handleMessageAndGetNazev = (socket: WebSocket) => new Promise<string | voi
return rej("nazev neexistuje");
}
if (typeof nazev != "string") {
return rej("nazev neni string");
}
clearTimeout(timeout);
socket.off("message", listener);
res(nazev);
@ -182,8 +186,17 @@ async function urobit() {
kdyToBude.setHours(20);
kdyToBude.setSeconds(0);
let nazev = "";
try {
nazev = await ziskatNazev();
} catch (e) {
logg("nepodarilo se ziskat nazev, pouzivam default");
nazev = "Vordinačka";
}
const event = await guilda.scheduledEvents.create({
name: (await ziskatNazev()) || "Vordinačka",
name: nazev,
scheduledStartTime: kdyToBude,
entityType: GuildScheduledEventEntityType.Voice,
privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,