added pgn random
This commit is contained in:
parent
cdfe219609
commit
1297ef467e
@ -4,7 +4,7 @@ import { GuildMember, Message, Role, VoiceState } from "discord.js";
|
||||
import fetch from "node-fetch";
|
||||
import { emouty } from "../utils/emotes";
|
||||
import { Modul, Spinkackar } from "../utils/types";
|
||||
import { formatCas, formatter, ping } from "../utils/utils";
|
||||
import { formatCas, formatter, oddiakritikovat, ping } from "../utils/utils";
|
||||
|
||||
let spinkacky: Record<string, Spinkackar>;
|
||||
const budouciSpinky: Record<string, NodeJS.Timeout> = {};
|
||||
@ -42,6 +42,17 @@ const handleSpink = async (act: "spinkacek" | "vstavacek", member: GuildMember)
|
||||
return ok.startsWith("OK") ? ok : false;
|
||||
};
|
||||
|
||||
const ifUzRemove = (m: Message) => {
|
||||
const id = m.author.id;
|
||||
const uzPgn = budouciSpinky[id];
|
||||
if (uzPgn) {
|
||||
clearTimeout(uzPgn);
|
||||
delete budouciSpinky[id];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const exp: Modul = {
|
||||
more_komandy: {
|
||||
|
||||
@ -51,11 +62,7 @@ const exp: Modul = {
|
||||
if (mes.author.bot) return `až někdy${emouty.kapp}`;
|
||||
if (await handleSpink("spinkacek", mes.member!)) {
|
||||
mes.react(emouty.spinkacek);
|
||||
const uz = budouciSpinky[mes.author.id];
|
||||
if (uz) {
|
||||
clearTimeout(uz);
|
||||
delete budouciSpinky[mes.author.id];
|
||||
}
|
||||
ifUzRemove(mes);
|
||||
}
|
||||
else return 'nespis uz?????';
|
||||
}
|
||||
@ -89,8 +96,13 @@ const exp: Modul = {
|
||||
const ted = new Date();
|
||||
const tedT = Number(ted);
|
||||
const spink = new Date();
|
||||
let random = false;
|
||||
|
||||
if (/^\d+$/.test(kdy) || !kdy)
|
||||
if (kdy == "random") {
|
||||
random = true;
|
||||
spink.setSeconds(Math.random() * 10740 + 60);
|
||||
console.log(`random spink pro ${oddiakritikovat(mes.member?.displayName || "neznamejmeno")} byl nastaven na ${formatter(spink)}`);
|
||||
} else if (/^\d+$/.test(kdy) || !kdy)
|
||||
spink.setTime(tedT + Number(kdy || 7200) * 1000);
|
||||
else {
|
||||
const cojavim = /^((?<d>\d+)\. ?((?<mo>\d+)\.)? ?|(?<z>z([ií]|ej)tra) )?(?<h>\d+)(:(?<m>\d+)(:(?<s>\d+))?)? ?(?<p>am|pm)?$/.exec(kdy.toLowerCase());
|
||||
@ -107,14 +119,11 @@ const exp: Modul = {
|
||||
if (Number(spink) < tedT) return "to uz bylo ty magore";
|
||||
}
|
||||
|
||||
const uzPgn = budouciSpinky[mes.author.id];
|
||||
if (uzPgn) {
|
||||
clearTimeout(uzPgn);
|
||||
delete budouciSpinky[mes.author.id];
|
||||
}
|
||||
ifUzRemove(mes);
|
||||
|
||||
budouciSpinky[mes.author.id] = setTimeout(() => handleSpink("spinkacek", mes.member!), Number(spink) - tedT);
|
||||
return `tvuj spinkacek byl naplanovan na ${formatter(spink)}`;
|
||||
if (!random) return `tvuj spinkacek byl naplanovan na ${formatter(spink)}`;
|
||||
mes.react(emouty.lajk);
|
||||
}
|
||||
},
|
||||
|
||||
@ -134,10 +143,7 @@ const exp: Modul = {
|
||||
zruspgn: {
|
||||
als: ["zpgn", "cancelpgn", "cpgn", "unpgn", `unp${emouty.gn}`],
|
||||
run: (mes) => {
|
||||
const jehoSpink = budouciSpinky[mes.author.id];
|
||||
if (!jehoSpink) return `spinkacek ale nemas naplanovanej ty kkte ${mes.author}`;
|
||||
clearTimeout(jehoSpink);
|
||||
delete budouciSpinky[mes.author.id];
|
||||
if (!ifUzRemove(mes)) return `spinkacek ale nemas naplanovanej ty kkte ${mes.author}`;
|
||||
return "to bylo teda trapny debile";
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,5 +7,7 @@ export enum emouty {
|
||||
d3k = "<:D3K:730175107313565717>",
|
||||
kapp = "<:kapp:677916836418813953>",
|
||||
spinkacek = "<:spinkacek:761652251966046208>",
|
||||
sjeta = "<:sjeta:623216247953424426>"
|
||||
sjeta = "<:sjeta:623216247953424426>",
|
||||
gn = "<:gn:887124590583746590>",
|
||||
lajk = "<:lajk:851556768373932123>"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user