import { getVoiceConnections } from "@discordjs/voice";
import { emouty } from "../utils/emotes";
import { Modul } from "../utils/types";
import { prefix, messageReply } from "../utils/utils";
import { novejLeave } from "../utils/voice";

let spim = false;

const exp: Modul = {
	super_on_messageCreate: {
		pos: 0,
		fun: mes => {
			const cont = mes.content.toLowerCase();
			if (cont == `${prefix} zapni se`) {
				if (spim) {
					spim = false;
					mes.client.user?.setStatus("online");
					messageReply(mes, "dobré ráno magoří");
				}
				else messageReply(mes, "tak jsi kokot?");
			} else if (!spim) {
				if (cont == `${prefix} vypni se`) {
					mes.react(emouty.purfieRIP);
					getVoiceConnections().forEach(con => novejLeave(con.joinConfig.guildId));
					mes.client.user?.setStatus("invisible");
					spim = true;
				}
				else return false;
			}
			return true;
		}
	},
};

module.exports = exp;
