From 18c6557349e84aafde285e494bd81b7ed4e1f9b7 Mon Sep 17 00:00:00 2001 From: det-fys Date: Fri, 13 Nov 2020 18:25:56 +0100 Subject: [PATCH 1/5] Update app.js rekniCas2 --- app.js | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index fd5fd8d..e4477e5 100644 --- a/app.js +++ b/app.js @@ -24,6 +24,38 @@ const rekniCas = (par = null) => { setTimeout(rekniCas, 30 - ickon/1000 % 30); }; +function vypocitatCas(vojsl) { + let c = new Date(); + let d = new Date(); + let hod = d.getHours(); + let min = d.getMinutes(); + if (min >= /*30*/ 20) { + min = 0; + hod = hod == 23 ? 0 : hod + 1; + c = new Date(c.getDate() + 1); + } else { + min = 30; + } + d.setHours(hod); + d.setMinutes(min); + + setTimeout(function() { + rekniCas2(vojsl, `${nula(hod)}${nula(min)}`); + }, c - d); +} + +function rekniCas2(vojsl, cas) { + if (!vojsl) return; + const disp = vojs.play(`./zvuky/${cas}.mp3`); + disp.on('finish', () => vojs.play('./zvuky/grg.mp3')); + + vypocitatCas(vojsl); +} + +function nula(a) { + return a < 10 ? "0" + a : a; +} + client.on('ready', () => console.log('A jedeš!')); client.on('message', mes => { @@ -103,12 +135,12 @@ client.on('message', mes => { mes.channel.send(`di si tam sam ne ty gadzo ${mes.author}`); break; } - channel.join() - .then(con => vojs = con); + if (!mes.content.includes('potichu')) mes.channel.send('<@&591306633196339261> vojs'); - const ickon = new Date(); - setTimeout(rekniCas, 30 - ickon/1000 % 30); + /*const ickon = new Date(); + setTimeout(rekniCas, 30 - ickon/1000 % 30);*/ + channel.join().then(con => vypocitatCas(con)); break; case 'wojs': From f7d72d17fad7b86df15e4fa5a7f72f8b5992fd36 Mon Sep 17 00:00:00 2001 From: det-fys Date: Fri, 13 Nov 2020 18:28:24 +0100 Subject: [PATCH 2/5] Update app.js --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index e4477e5..89ac040 100644 --- a/app.js +++ b/app.js @@ -29,7 +29,7 @@ function vypocitatCas(vojsl) { let d = new Date(); let hod = d.getHours(); let min = d.getMinutes(); - if (min >= /*30*/ 20) { + if (min > 25 && min < 55) { min = 0; hod = hod == 23 ? 0 : hod + 1; c = new Date(c.getDate() + 1); From f5afc023f74eeed41307375acf9079b9d8dd470d Mon Sep 17 00:00:00 2001 From: det-fys Date: Fri, 13 Nov 2020 18:32:13 +0100 Subject: [PATCH 3/5] Update app.js --- app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 89ac040..26b65b5 100644 --- a/app.js +++ b/app.js @@ -31,8 +31,12 @@ function vypocitatCas(vojsl) { let min = d.getMinutes(); if (min > 25 && min < 55) { min = 0; - hod = hod == 23 ? 0 : hod + 1; - c = new Date(c.getDate() + 1); + if (hod == 23) { + hod = 0; + c = new Date(c.getDate() + 1); + } else { + hod++; + } } else { min = 30; } From 957c0869a616dd225c2d4c8c97b1352194cb84b6 Mon Sep 17 00:00:00 2001 From: det-fys Date: Fri, 13 Nov 2020 18:36:32 +0100 Subject: [PATCH 4/5] Update app.js --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 26b65b5..35b94ee 100644 --- a/app.js +++ b/app.js @@ -45,7 +45,7 @@ function vypocitatCas(vojsl) { setTimeout(function() { rekniCas2(vojsl, `${nula(hod)}${nula(min)}`); - }, c - d); + }, d - c); } function rekniCas2(vojsl, cas) { From 0ffd98404083ab1409418df74a98558bd21a113e Mon Sep 17 00:00:00 2001 From: det-fys Date: Fri, 13 Nov 2020 18:40:44 +0100 Subject: [PATCH 5/5] Update app.js --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 35b94ee..1a9512e 100644 --- a/app.js +++ b/app.js @@ -50,8 +50,8 @@ function vypocitatCas(vojsl) { function rekniCas2(vojsl, cas) { if (!vojsl) return; - const disp = vojs.play(`./zvuky/${cas}.mp3`); - disp.on('finish', () => vojs.play('./zvuky/grg.mp3')); + const disp = vojsl.play(`./zvuky/${cas}.mp3`); + disp.on('finish', () => vojsl.play('./zvuky/grg.mp3')); vypocitatCas(vojsl); }