From 3e97196d0f8c6e4c1b94c18e4352748a5a60c823 Mon Sep 17 00:00:00 2001 From: Histmy Date: Wed, 23 Dec 2020 02:51:09 +0100 Subject: [PATCH] Added more vytah (finally) + some formating --- app.js | 2 +- modules/vojs.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index cd65bb3..3b4bbf5 100644 --- a/app.js +++ b/app.js @@ -16,6 +16,7 @@ client.on('ready', () => console.log('A jedeš!')); client.on('message', mes => { if (process.env.IGNORE_MESS) return; + const [mes_prefix, komand, ...args] = mes.content.toLowerCase().split(' '); if (mes_prefix === prefix) { const celArgs = args.join(' '); @@ -30,7 +31,6 @@ client.on('message', mes => { if (mes.content.toLowerCase().includes(sp)) sance++; }); if (rand(3) < sance) mes.react(emouty[rand(emouty.length)]); - }); client.on('presenceUpdate', (bef, aft) => { diff --git a/modules/vojs.js b/modules/vojs.js index bdc83bd..9d0cbd0 100644 --- a/modules/vojs.js +++ b/modules/vojs.js @@ -40,6 +40,22 @@ function nula(a) { return a < 10 ? "0" + a : a; } +const vytahnout = (clen, patro) => { + const vojs = clen.voice + if (!vojs) return; + + const aktPatro = Number(vojs.channel.name) || 0; + let dalsiPatro = aktPatro; + if (patro < aktPatro) dalsiPatro--; else if (patro > aktPatro) dalsiPatro++; else return; + if (dalsiPatro === 0) dalsiPatro = 'P'; + + const dalsiVojsy = [...clen.guild.channels.cache.values()].filter(channel => channel.type === 'voice' && channel.name === String(dalsiPatro)); + if (!dalsiVojsy) return; + + clen.voice.setChannel(dalsiVojsy[0]); + setTimeout(() => vytahnout(clen, patro), 1000); +}; + module.exports = (mes, komand, celArgs) => { switch (komand) { @@ -81,6 +97,17 @@ module.exports = (mes, komand, celArgs) => { mes.react('purfieRIP:644609482843881483'); break; + case 'vitah': + case 'vytah': + console.log(celArgs, Boolean(celArgs)); + if (!celArgs) { + mes.channel.send(`napis do jakiho patra ${mes.author}`); + break; + } + + vytahnout(mes.member, Number(celArgs) || 0); + break; + default: return false; }