From 2ad65d54ff7778774ba9bb9a8f8607bbbb38cd93 Mon Sep 17 00:00:00 2001 From: Histmy Date: Sun, 29 Aug 2021 00:52:38 +0200 Subject: [PATCH] if vojs potichu, nazdar not played --- src/modules/vojs.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/vojs.ts b/src/modules/vojs.ts index 367521d..57cc737 100644 --- a/src/modules/vojs.ts +++ b/src/modules/vojs.ts @@ -67,20 +67,21 @@ module.exports = { const channel = mes.member?.voice.channel; if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`; - if (arg !== "potichu") mes.channel.send("<@&591306633196339261> vojs"); + const nahlas = arg !== "potichu"; + if (nahlas) mes.channel.send("<@&591306633196339261> vojs"); joinVoice(channel) .then(obj => { - const conn = obj.conn; + const { prev, conn } = obj; if (!timeouty[mes.guildId!]) { vypocitatCas(conn); - conn.on(VoiceConnectionStatus.Disconnected, () => conn.destroy()); - conn.on(VoiceConnectionStatus.Destroyed, () => { + conn.on("stateChange", (_, now) => { + if (now.status !== VoiceConnectionStatus.Disconnected && now.status !== VoiceConnectionStatus.Destroyed) return; clearTimeout(timeouty[mes.guildId!]); delete timeouty[mes.guildId!]; }); } - play(conn, "zvuky/nazdar.ogg"); + if (prev !== true && nahlas) play(conn, "zvuky/nazdar.ogg"); }); } },