// Tento modul je zasvěcen komandům, které je potřeba zachovat a jsou tak primitivní, že se dají zkombinovat do jednoho kompaktního souboru.

import { ActivityType, ChannelType, Message, PresenceStatusData } from "discord.js";
import { emouty } from "../utils/emotes";
import { Modul } from "../utils/types";
import { formatCas, ping, rand } from "../utils/utils";

const pomoc: [string[], Record<string, unknown>] = require("../../res/pomoc.json");
const ftipy: string[] = require("../../res/ftipy.json");

const delAndReturn = (mes: Message, co: string) => {
	if (mes.channel.type != ChannelType.DM) mes.delete().catch();
	return co;
};

const changeStatus = (mes: Message, status: PresenceStatusData) => {
	mes.client.user?.setStatus(status);
	return "ano pane";
};

const changeActivity = (mes: Message, activity: Exclude<ActivityType, ActivityType.Custom> | undefined = undefined, txt: string = "") => {
	mes.client.user?.setActivity(txt, { type: activity });
	mes.react(emouty.d3k);
	return "ano pane";
};

const choose = (arr: string[]) => arr[rand(arr.length)];

const exp: Modul = {
	more_komandy: {
		vole: "coe voe more gadzo",

		kobel: "kde?",

		ano: {
			als: ["jo", "ne"],
			run: "ok"
		},

		rekt: "**ouuuuuuuuuuuuuuuuuuuuu**",

		omegasmart: "<:DENIM3K_OMEGASMART1:638103812892131328><:DENIM3K_OMEGASMART2:638104266195861514><:DENIM3K_OMEGASMART3:638104266178822155>\n<:DENIM3K_OMEGASMART4:638104266246062180><:DENIM3K_OMEGASMART5:638104266241867787><:DENIM3K_OMEGASMART6:638104265889546241>\n<:DENIM3K_OMEGASMART7:638104266267033610><:DENIM3K_OMEGASMART8:638104266271096882><:DENIM3K_OMEGASMART9:638104266258513960>",

		lag: "protoze to spousti na tich stravberi",

		triggered: "toto me trickeruje",

		slak: "te natahne\nhttps://tenor.com/view/tired-done-imdone-afterschool-school-gif-5682065",

		pomoc: pomoc[0].join("\n"),

		pomoc2: () => { return { embeds: [pomoc[1]] }; },

		pomoc3: `${emouty.lukiw} :point_right: https://denim3001.deadfish.cz/morepomoc`,

		verze: () => `${require("../../package.json").version}\nčenžlog mas tady https://denim3001.deadfish.cz/morehovna`,

		navrh: "tadi mas prostor https://navrhy.denim3001.deadfish.cz/",

		uptime: () => `uz jedu ${formatCas(Math.round(globalThis.performance.now() / 1000))}`,

		rekni: (mes, co) => {
			if (mes.author.bot) return "ne";
			return delAndReturn(mes, co || `co mam jako rict ${mes.author}`);
		},

		clap: (mes, text) => {
			return delAndReturn(mes, `${text} ${emouty.clap}`);
		},

		clap2: (mes, text) => {
			return delAndReturn(mes, `${emouty.clap2} ${text}`);
		},

		voliz: (mes, co) => {
			return delAndReturn(mes, `${emouty.lickL}${co}${emouty.lickR}`);
		},

		pozdrav: (_, koho) => `zdravim ${koho}`,

		zhejti: (_, koho) => `${koho} je pycovina zasrana vimrdana`,

		uraz: (_, koho) => `${koho} , u suck`,

		online: {
			als: ["onlajn", "zelenej"],
			run: mes => changeStatus(mes, "online")
		},
		idle: {
			als: ["zlutej", "afk", "idle", "nepritomnej"],
			run: mes => changeStatus(mes, "idle")
		},
		dnd: {
			als: ["nerusit", "cervenej"],
			run: mes => changeStatus(mes, "dnd")
		},
		offline: {
			als: ["oflajn", "neviditelnej"],
			run: mes => changeStatus(mes, "invisible")
		},

		hraj: (mes, co) => changeActivity(mes, ActivityType.Playing, co),
		sleduj: (mes, co) => changeActivity(mes, ActivityType.Watching, co),
		poslouchej: (mes, co) => changeActivity(mes, ActivityType.Listening, co),
		soutez: (mes, vcem) => changeActivity(mes, ActivityType.Competing, vcem),
		nedelej: mes => changeActivity(mes),

		vtip: {
			als: ["ftip"],
			run: () => choose(ftipy)
		},

		kam: () => choose(["na šroťák", "na vrakoviště", "na smetiště", "do kontejneru", "na skládku", "do kriminálu", "pod most", "do sběru", "do hospody", "do najt klubu", "na folmavu"]),

		je: {
			arg: "kdo/co",
			run: () => rand(2) ? "jo je" : "ne neni"
		},

		ma: {
			arg: "kdo/co",
			run: () => rand(2) ? "jo ma" : "ne nema"
		},

		nazor: {
			arg: "koho/co",
			run: (_, arg) => rand(2) ? `mam rad ${arg}` : `${arg} je picovina`
		},

		si: {
			als: ["jsi"],
			run: (_, co) => {
				const corict = co.replace(/\?/g, "");
				return rand(2) ? `jo sem ${corict}` : `ne nejsem ${corict}`;
			}
		},

		mas: (_, co) => {
			const corict = co.replace(/\?/g, "");
			return rand(2) ? `jo mam ${corict}` : `ne nemam ${corict}`;
		},

		jakmoc: {
			run: (_, co) => `${co} na ${rand(101)}%`
		},


		jakmoc0: {
			run: (_, co) => `${co} na ${rand(1001)}‰`
		},

		uz: {
			als: ["uz?"],
			run: () => choose(["ne", "jeste ne", "jiz brzy", "za chvili", "vubec", "nikdy", "za dlouho", "za 5 let", "zejtra", "davno", "jo", "mozna"])
		},

		vyber: {
			arg: "co (odděleno čárkami nebo \"|\")",
			run: (_, arg) => {
				if (!arg.length) return "co vole";
				const moznosti = arg.split(arg.indexOf("|") > -1 ? "|" : ",").filter(m => m.length);
				return choose(moznosti) || "kokot";
			}
		},

		fight: {
			als: ["figh", "fajt"],
			run: (mes, skym) => {
				if (!ping.test(skym)) return "tak si kokot ti kokote";

				const vyherce = Math.random() < 0.5 ? mes.author : skym;
				return `tento figh vyhrál: ${vyherce}!`;
			}
		}
	}
};

module.exports = exp;
