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;
};
client.on("messageCreate", mes => {
client.on("messageCreate", async mes => {
if (process.env.ignoreMess) return;
const [mes_prefix, komandSDiakritikou, ...args] = mes.content.split(" ");
@ -94,7 +94,7 @@ client.on("messageCreate", mes => {
const akce = cmd.run;
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);
});

View File

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

View File

@ -38,25 +38,22 @@ module.exports = {
spinkacek: {
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}`;
(async () => {
if (await contactSpinkServer('spinkacek', mes.author.id, mes.author.username, mes.author.avatarURL()) === "OK")
mes.react(emouty.spinkacek);
else mes.channel.send('nespis uz?????');
})();
else return 'nespis uz?????';
}
},
vstavacek: {
als: ["vstavcacek", "gm"],
run: (_: any, mes: Message) => {
run: async (_: any, mes: Message) => {
if (mes.author.bot) return emouty.sjeta;
(async () => {
const odpoved = await contactSpinkServer('vstavacek', mes.author.id);
const [ok, casTxt] = odpoved.split(" ");
const cas = Number(casTxt);
if (ok !== "OK") return mes.channel.send("uz jsi vzhuru ty hajzle");
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";
@ -64,8 +61,7 @@ module.exports = {
else if (cas >= 36000) zpr = "fakt bídák";
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;
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");
joinVoice(channel)
@ -112,7 +112,7 @@ module.exports = {
als: ["krk", "grg", "grgnisi", "krknisi", "grgacek"],
run: async (_: any, mes: Message) => {
const channel = mes.member?.voice.channel;
if (!channel) return mes.channel.send("***grrrrrrrrg***");
if (!channel) return "***grrrrrrrrg***";
const { conn, prev } = await joinVoice(channel);
await play(conn, "zvuky/grg.mp3");
@ -145,7 +145,7 @@ module.exports = {
const je = h > 1 && h < 5 ? "jsou" : "je";
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 }];