From d8c9c24da8bb6b6f3d46ae8e8b5edf9100d3e3ac Mon Sep 17 00:00:00 2001 From: Histmy Date: Wed, 30 Nov 2022 14:30:49 +0100 Subject: [PATCH] =?UTF-8?q?lep=C5=A1=C3=AD=20startova=C4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/onReady.ts | 2 +- src/modules/zbytek.ts | 7 ++++--- src/utils/utils.ts | 5 ++++- start.sh | 19 ++++++++++++------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/modules/onReady.ts b/src/modules/onReady.ts index 06533a1..bbc921e 100644 --- a/src/modules/onReady.ts +++ b/src/modules/onReady.ts @@ -7,7 +7,7 @@ import { adminLog, log } from "../utils/utils"; const exp: Modul = { on_ready: async () => { log("A jedeš!"); - if (process.argv.length < 3) return; + if (process.argv.length < 4) return; const client: Client = module.exports.client; adminLog(client, "pošel jsem"); } diff --git a/src/modules/zbytek.ts b/src/modules/zbytek.ts index 6d733f9..5c51704 100644 --- a/src/modules/zbytek.ts +++ b/src/modules/zbytek.ts @@ -40,9 +40,10 @@ const exp: Modul = { }, lastuptime: () => { - const cislo = Number(process.argv[2]); - if (!cislo) return "aj forgor 💀"; - return `naposled jsem jel ${formatCas(cislo)}`; + const index = process.argv.length > 3 ? 3 : 2; + const sekundy = Number(process.argv[index]); + if (!sekundy) return "aj forgor 💀"; + return `naposled jsem jel ${formatCas(sekundy)}`; } }, diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 44faa9a..a73565b 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -84,7 +84,10 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g return { conn, prev: true }; } prev = conn.joinConfig.channelId!; - if (!prev) throw new Error(`Ty si fakt dement @histmy, ${typeof prev}`); + if (!prev) { + log(new Error(`chci do kanelu "${channelId}", na serveru "${guildId}" a config channelid nen`)); + throw new Error("Dement no"); + } } conn = joinVoiceChannel({ diff --git a/start.sh b/start.sh index 1524606..f84d6a2 100644 --- a/start.sh +++ b/start.sh @@ -1,24 +1,29 @@ +declare -a casy +i=0 while true do cas=$(date +"%s") - if node . $neco + if node . $posel $posledni then echo stahuju update git stash git pull npm i --omit=dev tsc >/dev/null - unset neco + unset posel else echo exit code byl $? - novejcas=$(date +"%s") - neco=$(($novejcas-$cas)) - if (($cas+86400<$novejcas)) + posel=1 + casy[$i]=$(date +"%s") + posledni=$(($((casy[$i]))-$cas)) + + if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($((casy[$i])) - 864000)))) then - echo Poslo to, let\'s restart + echo Poslo to dostatecne malo, restartuju else - echo Poslo to absolutne, seru na to + echo Poslo to moc, seru na to break fi + i=$(($i+1)) fi done