// Modul dedikovaný funkci spinkáček import { Message, VoiceState } from "discord.js"; import fetch from "node-fetch"; import { emouty } from "../utils/emotes"; import { Spinkackar } from "../utils/types"; import { formatCas } from "../utils/utils"; const spinkacky: string[] = []; const contactSpinkServer = async (akce: string, id: string, nick: string = "", avatar: string | null = "") => { const options = `heslo=${process.env.spinkPass}&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); }; const syncSpink = async () => { await fetch("https://spinkacek.ga/api/spinkacky") .then(r => r.json() as Promise>) .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_komandy: { spinkacek: { als: ["spink", "spoink", "spinkake", "spoinkacek", "gn"], run: async (_: any, mes: Message) => { if (mes.author.bot) return `až někdy${emouty.kapp}`; if (await contactSpinkServer('spinkacek', mes.author.id, mes.author.username, mes.author.avatarURL()) === "OK") mes.react(emouty.spinkacek); else return 'nespis uz?????'; } }, vstavacek: { als: ["vstavcacek", "gm"], run: async (_: any, mes: Message) => { if (mes.author.bot) return emouty.sjeta; const odpoved = await contactSpinkServer('vstavacek', mes.author.id); const [ok, casTxt] = odpoved.split(" "); const cas = Number(casTxt); if (ok !== "OK") return "uz jsi vzhuru ty hajzle"; const formatedCas = formatCas(cas); let zpr = ""; if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde"; else if (cas >= 43200) zpr = "extrémní bídák"; else if (cas >= 36000) zpr = "fakt bídák"; else if (cas < 10800) zpr = "dobrej fake spink debile"; return `dobry rano hajzle\nspal sy ${formatedCas}\n${zpr}`; } }, pgn: (kdy: string, mes: Message) => { if (mes.author.bot) return emouty.sjeta; const zaJakDlouho = Number(kdy) * 1000 || 7_200_000; const datum = new Date(Number(new Date()) + zaJakDlouho); const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month: "short", hour: "numeric", minute: "numeric", second: "numeric" }); setTimeout(() => contactSpinkServer("spinkacek", mes.author.id, mes.author.username, mes.author.avatarURL()), zaJakDlouho); return `Tvuj spinkacek byl naplanovan na ${formatter.format(datum)}`; } }, on_voiceStateUpdate: (bef: VoiceState, aft: VoiceState) => { if (!aft.channel || bef.channel) return; if (spinkacky.includes(aft.id)) aft.disconnect("spinkacek") .catch(err => console.log("spinkacek odpojit se nepovedlo nebo co:", err)); }, super_on_message: (mes: Message, cmd?: string) => { if (mes.author.id === '831318260493844494') { syncSpink(); if (mes.content[0] !== 's') return; const uzivatel = mes.content.match(/(?<=discord_)\d+/)?.[0]; if (!uzivatel) return; for (const [_, guild] of mes.client.guilds.cache) { for (const [_, channel] of guild.channels.cache) { if (channel.type !== "GUILD_VOICE") continue; for (const [_, member] of channel.members) { if (member.id !== uzivatel) continue; member.voice.disconnect("spinkacek"); return; } } } } else if (spinkacky.includes(mes.author.id) && cmd != "vstavacek") { mes.delete(); (async () => { const chanel = mes.author.dmChannel ?? await mes.author.createDM(); chanel.send("spis tak nepis"); })(); return true; } } };