Async message events can now return response

& fixed vojs potichu
This commit is contained in:
Histmy 2021-09-16 00:16:48 +02:00
parent 6369ea2720
commit 4a49094844
4 changed files with 30 additions and 38 deletions

View File

@ -73,7 +73,7 @@ const maKuldan = (id: string, komand: string, kuldan_komandu: number) => {
return 0; return 0;
}; };
client.on("messageCreate", mes => { client.on("messageCreate", async mes => {
if (process.env.ignoreMess) return; if (process.env.ignoreMess) return;
const [mes_prefix, komandSDiakritikou, ...args] = mes.content.split(" "); const [mes_prefix, komandSDiakritikou, ...args] = mes.content.split(" ");
@ -94,7 +94,7 @@ client.on("messageCreate", mes => {
const akce = cmd.run; const akce = cmd.run;
if (typeof akce === "string") return void mes.channel.send(akce); if (typeof akce === "string") return void mes.channel.send(akce);
const result = akce(celArgs, mes); const result = await akce(celArgs, mes);
if (typeof result == "string") mes.channel.send(result); if (typeof result == "string") mes.channel.send(result);
}); });

View File

@ -80,24 +80,20 @@ module.exports = {
zareaguj: { zareaguj: {
als: ["react"], als: ["react"],
run: (arg: string, mes: Message) => { run: async (arg: string, mes: Message) => {
if (!arg) return "retard";
const emouty = arg.match(/<a?:\w{1,32}:\d+>/g); const emouty = arg.match(/<a?:\w{1,32}:\d+>/g);
if (!emouty) return "retard"; if (!emouty) return "retard";
let naCo: Message; let naCo: Message;
(async () => { if (mes.reference) {
if (mes.reference) { naCo = await mes.channel.messages.fetch(mes.reference.messageId!);
naCo = await mes.channel.messages.fetch(mes.reference.messageId!); } else {
} else { const msgs = [...mes.channel.messages.cache.values()];
const msgs = [...mes.channel.messages.cache.values()]; naCo = msgs[msgs.length - 2];
naCo = msgs[msgs.length - 2]; }
}
mes.delete(); mes.delete();
emouty.forEach(emout => naCo.react(emout)); emouty.forEach(emout => naCo.react(emout));
})();
} }
}, },

View File

@ -38,34 +38,30 @@ module.exports = {
spinkacek: { spinkacek: {
als: ["spink", "spoink", "spinkake", "spoinkacek", "gn"], als: ["spink", "spoink", "spinkake", "spoinkacek", "gn"],
run: (_: any, mes: Message) => { run: async (_: any, mes: Message) => {
if (mes.author.bot) return `až někdy${emouty.kapp}`; if (mes.author.bot) return `až někdy${emouty.kapp}`;
(async () => { if (await contactSpinkServer('spinkacek', mes.author.id, mes.author.username, mes.author.avatarURL()) === "OK")
if (await contactSpinkServer('spinkacek', mes.author.id, mes.author.username, mes.author.avatarURL()) === "OK") mes.react(emouty.spinkacek);
mes.react(emouty.spinkacek); else return 'nespis uz?????';
else mes.channel.send('nespis uz?????');
})();
} }
}, },
vstavacek: { vstavacek: {
als: ["vstavcacek", "gm"], als: ["vstavcacek", "gm"],
run: (_: any, mes: Message) => { run: async (_: any, mes: Message) => {
if (mes.author.bot) return emouty.sjeta; if (mes.author.bot) return emouty.sjeta;
(async () => { const odpoved = await contactSpinkServer('vstavacek', mes.author.id);
const odpoved = await contactSpinkServer('vstavacek', mes.author.id); const [ok, casTxt] = odpoved.split(" ");
const [ok, casTxt] = odpoved.split(" "); const cas = Number(casTxt);
const cas = Number(casTxt); if (ok !== "OK") return "uz jsi vzhuru ty hajzle";
if (ok !== "OK") return mes.channel.send("uz jsi vzhuru ty hajzle"); const formatedCas = formatCas(cas);
const formatedCas = formatCas(cas); let zpr = "";
let zpr = ""; if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde";
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 >= 43200) zpr = "extrémní bídák"; else if (cas >= 36000) zpr = "fakt bídák";
else if (cas >= 36000) zpr = "fakt bídák"; else if (cas < 10800) zpr = "dobrej fake spink debile";
else if (cas < 10800) zpr = "dobrej fake spink debile";
mes.channel.send(`dobry rano hajzle\nspal sy ${formatedCas}\n${zpr}`); return `dobry rano hajzle\nspal sy ${formatedCas}\n${zpr}`;
})();
} }
} }
}, },

View File

@ -68,7 +68,7 @@ module.exports = {
const channel = mes.member?.voice.channel; const channel = mes.member?.voice.channel;
if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`; if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`;
const nahlas = arg !== "potichu"; const nahlas = arg.startsWith("potichu");
if (nahlas) mes.channel.send("<@&591306633196339261> vojs"); if (nahlas) mes.channel.send("<@&591306633196339261> vojs");
joinVoice(channel) joinVoice(channel)
@ -112,7 +112,7 @@ module.exports = {
als: ["krk", "grg", "grgnisi", "krknisi", "grgacek"], als: ["krk", "grg", "grgnisi", "krknisi", "grgacek"],
run: async (_: any, mes: Message) => { run: async (_: any, mes: Message) => {
const channel = mes.member?.voice.channel; const channel = mes.member?.voice.channel;
if (!channel) return mes.channel.send("***grrrrrrrrg***"); if (!channel) return "***grrrrrrrrg***";
const { conn, prev } = await joinVoice(channel); const { conn, prev } = await joinVoice(channel);
await play(conn, "zvuky/grg.mp3"); await play(conn, "zvuky/grg.mp3");
@ -145,7 +145,7 @@ module.exports = {
const je = h > 1 && h < 5 ? "jsou" : "je"; const je = h > 1 && h < 5 ? "jsou" : "je";
const channel = mes.member?.voice.channel; const channel = mes.member?.voice.channel;
if (!channel) return mes.channel.send(`${je} ${h} ${hod} ${m} ${min}`); if (!channel) return `${je} ${h} ${hod} ${m} ${min}`;
const zvuky: MuzikaFace[] = [{ name: `${pre}${je}.mp3`, volume: 2.5 }]; const zvuky: MuzikaFace[] = [{ name: `${pre}${je}.mp3`, volume: 2.5 }];