diff --git a/.gitignore b/.gitignore index 210b209..710c3bf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules denim3001 - origo nahravky +zvuky/placeholder.ogg diff --git a/app.js b/app.js index 49cc80b..e5c8918 100644 --- a/app.js +++ b/app.js @@ -46,5 +46,32 @@ client.on('presenceUpdate', (bef, aft) => { console.log(`${aft.user.username} změnil status z ${bef.status} na ${aft.status}`); }); -client.login(process.env.TOKEN); +client.on('voiceStateUpdate', (bef, aft) => { + if (!aft.channel || !aft.guild.voice || aft.member.user === client.user) return; + // const vysvetleni = (user, vojs = undefined) => { + // const con = aft.guild.voice.connection; + // const disp = con.play('./zvuky/neodposlouchavej.ogg'); + // disp.on('finish', () => { + // user.setDeaf(true, 'otposlouchávala ta gadza'); + // if (vojs) con.voice.setChannel(vojs); + // }); + // } + + if (aft.mute && !aft.deaf) { + // if (aft.guild.voice.channel !== aft.channel) { + // const vojsBack = aft.guild.voice.channel; + // aft.guild.voice.setChannel(aft.channel) + // .then(() => vysvetleni(aft, vojsBack)); + // return; + // } + // vysvetleni(aft); + const disp = aft.guild.voice.connection.play('./zvuky/neodposlouchavej.ogg'); + disp.on('finish', () => user.setDeaf(true, 'otposlouchávala ta gadza')); + } + + if (!bef.channel) return; + if (bef.mute && bef.deaf && !aft.mute && aft.deaf) aft.setDeaf(false, 'us muze poslouchat gaza'); +}); + +client.login(process.env.TOKEN); diff --git a/zvuky/neodposlouchavej.ogg b/zvuky/neodposlouchavej.ogg new file mode 100644 index 0000000..f7f61d7 Binary files /dev/null and b/zvuky/neodposlouchavej.ogg differ