88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
// Modul dedikovaný funkci spinkáček
|
|
|
|
const fetch = require('node-fetch');
|
|
const spinkacky = [];
|
|
|
|
const contactSpinkServer = async (akce, id, nick, avatar) => {
|
|
const options = `heslo=${process.env.SPINK_PASS}&akce=${akce}&id=${id}&nick=${encodeURIComponent(nick)}&avatar=${encodeURIComponent(avatar)}`;
|
|
return await fetch(`https://spinkacek.ga/extapi.php?${options}`)
|
|
.then(r => r.text())
|
|
.then(text => text === 'OK');
|
|
};
|
|
|
|
const syncSpink = async () => {
|
|
await fetch('https://spinkacek.ga/api/spinkacky')
|
|
.then(r => r.json())
|
|
.then(d => {
|
|
const data = d.spinkacky;
|
|
const keys = Object.keys(data);
|
|
const values = Object.values(data);
|
|
spinkacky.splice(0);
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
if (!values[i].spinkacek || keys[i][0] === 'i') continue;
|
|
spinkacky.push(keys[i].slice(8));
|
|
}
|
|
});
|
|
};
|
|
|
|
syncSpink();
|
|
|
|
module.exports = {
|
|
more_komand: (mes, komand) => {
|
|
switch (komand) {
|
|
|
|
case 'spinkáček':
|
|
case 'spinkacek':
|
|
if (mes.author.bot) {
|
|
mes.channel.send("až někdy<:kapp:677916836418813953>");
|
|
break;
|
|
}
|
|
(async () => {
|
|
if (await contactSpinkServer('spinkacek', mes.author.id, mes.author.username, mes.author.avatarURL())) mes.react("761652251966046208");
|
|
else mes.channel.send('nespis uz?????');
|
|
})();
|
|
break;
|
|
|
|
case 'vstáváček':
|
|
case 'vstavacek':
|
|
if (mes.author.bot) {
|
|
mes.channel.send("<:sjeta:623216247953424426>");
|
|
break;
|
|
}
|
|
(async () => {
|
|
if (await contactSpinkServer('vstavacek', mes.author.id)) mes.channel.send('dobre rano hajzle');
|
|
else mes.channel.send('uz jsi vzhuru ty hajzle');
|
|
})();
|
|
break;
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
on_voiceStateUpdate: (bef, aft) => {
|
|
if (!aft.channel || bef.channel) return;
|
|
if (spinkacky.includes(aft.id)) aft.kick()
|
|
.catch(() => { });
|
|
},
|
|
|
|
on_message: mes => {
|
|
if (mes.author.id === '831318260493844494') {
|
|
syncSpink();
|
|
if (mes.content[0] !== 's') return;
|
|
const uzivatel = mes.content.match(/(?<=discord_)\d+/)?.[0];
|
|
if (!uzivatel) return;
|
|
[...mes.client.guilds.cache.values()].forEach(guild => {
|
|
[...guild.channels.cache.values()].filter(ch => ch.type === 'voice').forEach(channel => {
|
|
[...channel.members.values()].forEach(user => {
|
|
if (user.user.id !== uzivatel) return;
|
|
user.voice.kick('spinkacek');
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
};
|