From 7f789bc0e760f41292aa29d386c3b862235cd27f Mon Sep 17 00:00:00 2001 From: Histmy Date: Thu, 15 Jun 2023 21:04:36 +0200 Subject: [PATCH] a hned updejt purfieKUK --- src/utils/utils.ts | 70 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index c2ccb04..e23a3c4 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -8,6 +8,32 @@ import { appendFileSync, existsSync } from "fs"; const pripojeni: SRecord = {}; const timeAnouncability: SRecord = {}; +const zajimavyUzivatele: SRecord = { + "1002340891178053652": "0", + "362267256329338882": "1", + "321300980249526272": "2", + "403199237170528256": "3", + "404374791253000194": "4", + "435109967222013952": "5", + "478227285158264832": "6", + "272393325808582656": "7", + "222004187494481921": "8", + "858340006783615006": "9", + "688169800710750211": "a", + "474828395654414336": "b", + "221561136028450816": "c", + "287318873286377472": "d", + "519942360520720394": "e", + "861116768747782163": "f", + "414116351863685121": "g", + "307954132638105601": "h", + "440080748251185152": "i", + "355053867265818635": "j", + "471010846668226561": "k", + "442754524697067520": "l", + "489076647727857685": "m" +}; + if (!existsSync("config.json")) throw new Error("config.json neexistuje"); process.env = { ...process.env, ...require("../../config.json") }; @@ -95,20 +121,42 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g }); //#region Dočasná statistika mluvení ve vojsu - appendFileSync("zaznamy.dlog", `nazdardebile${Date.now().toString(36)}\n`); + if (guildId == "555779161067749446") { + let base: number; + let interval: NodeJS.Timer; + function restart() { + base = Date.now() - 36; + appendFileSync("zaznamy.dlog", `nazdardebile${base.toString(36)}\n`); + interval = setInterval(() => { + base = Date.now() - 36; + appendFileSync("zaznamy.dlog", `hb${base.toString(36)}\n`); + }, 1000 * 60 * 25); + } + restart(); - conn.receiver.speaking.on("start", id => { - appendFileSync("zaznamy.dlog", `${parseInt(id).toString(36)} ${Date.now().toString(36)}\n`); - }); + conn.receiver.speaking.on("start", id => { + const ajdy = zajimavyUzivatele[id] ?? id; + const cas = (Date.now() - base).toString(36); + appendFileSync("zaznamy.dlog", `${ajdy} ${cas}\n`); + }); - conn.receiver.speaking.on("end", id => { - appendFileSync("zaznamy.dlog", `${Date.now().toString(36)} ${parseInt(id).toString(36)}\n`); - }); + conn.receiver.speaking.on("end", id => { + const ajdy = zajimavyUzivatele[id] ?? id; + const cas = (Date.now() - base).toString(36); + appendFileSync("zaznamy.dlog", `${cas} ${ajdy}\n`); + }); - conn.on("stateChange", (_, now) => { - if (now.status !== VoiceConnectionStatus.Disconnected && now.status !== VoiceConnectionStatus.Destroyed) return; - appendFileSync("zaznamy.dlog", `odtahnuljsem${Date.now().toString(36)}\n`); - }); + conn.on("stateChange", (prev, now) => { + if (now.status === VoiceConnectionStatus.Ready && prev.status !== VoiceConnectionStatus.Ready) { + clearInterval(interval); + return restart(); + } + + if (now.status === VoiceConnectionStatus.Disconnected || now.status === VoiceConnectionStatus.Destroyed) { + appendFileSync("zaznamy.dlog", `odtahnuljsem${Date.now().toString(36)}\n`); + } + }); + } //#endregion if (!prev) {