Added cooldown for "je" and "jakmoc(0)"
This commit is contained in:
parent
67c6a2b170
commit
2d53444938
30
app.js
30
app.js
@ -1,5 +1,6 @@
|
|||||||
const { Client } = require('discord.js');
|
const { Client } = require('discord.js');
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const { formatCas } = require("./addons/utils");
|
||||||
|
|
||||||
const client = new Client();
|
const client = new Client();
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
@ -10,6 +11,7 @@ const eventy = { on_message: [] };
|
|||||||
const komandy = {};
|
const komandy = {};
|
||||||
const aliasy = {};
|
const aliasy = {};
|
||||||
let spink = false;
|
let spink = false;
|
||||||
|
const kuldan_log = {};
|
||||||
|
|
||||||
const runEvent = (name, args) => {
|
const runEvent = (name, args) => {
|
||||||
eventy[name].forEach(listener => {
|
eventy[name].forEach(listener => {
|
||||||
@ -32,10 +34,10 @@ fs.readdirSync(modulFolder).forEach(function (soubor) {
|
|||||||
Object.keys(modul[name]).forEach(cmdName => {
|
Object.keys(modul[name]).forEach(cmdName => {
|
||||||
const value = modul[name][cmdName];
|
const value = modul[name][cmdName];
|
||||||
if (typeof value !== "object") {
|
if (typeof value !== "object") {
|
||||||
komandy[cmdName] = value;
|
komandy[cmdName] = { run: value };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
komandy[cmdName] = value.run;
|
komandy[cmdName] = { run: value.run, cd: value.cd };
|
||||||
value.als?.forEach(al => aliasy[al] = cmdName);
|
value.als?.forEach(al => aliasy[al] = cmdName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,6 +65,17 @@ const spim = mes => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function maKuldan(id, komand, kuldan_komandu) {
|
||||||
|
if (!kuldan_log[komand]) kuldan_log[komand] = {};
|
||||||
|
|
||||||
|
const cas_ted = Date.now() / 1000;
|
||||||
|
const rozdil = cas_ted - kuldan_log[komand][id];
|
||||||
|
if (rozdil < kuldan_komandu) return kuldan_komandu - rozdil;
|
||||||
|
|
||||||
|
kuldan_log[komand][id] = cas_ted;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
client.on("message", function (mes) {
|
client.on("message", function (mes) {
|
||||||
if (process.env.IGNORE_MESS || spim(mes)) return;
|
if (process.env.IGNORE_MESS || spim(mes)) return;
|
||||||
|
|
||||||
@ -72,12 +85,19 @@ client.on("message", function (mes) {
|
|||||||
if (!komand) return mes.channel.send("coe voe");
|
if (!komand) return mes.channel.send("coe voe");
|
||||||
|
|
||||||
const celArgs = args.join(' ');
|
const celArgs = args.join(' ');
|
||||||
const cmd = aliasy[komand] ?? komand;
|
const cmdName = aliasy[komand] ?? komand;
|
||||||
const akce = komandy[cmd];
|
const cmd = komandy[cmdName];
|
||||||
|
const akce = cmd?.run;
|
||||||
if (!akce) return mes.channel.send("co to znamena ti gadzovko");
|
if (!akce) return mes.channel.send("co to znamena ti gadzovko");
|
||||||
|
|
||||||
|
if (cmd.cd) {
|
||||||
|
const zbyva = Math.round(maKuldan(mes.author.id, cmdName, cmd.cd));
|
||||||
|
if (zbyva) return mes.channel.send(`si kkt vole maz kuldan jeste ${formatCas(zbyva)}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof akce === "string") return mes.channel.send(akce);
|
if (typeof akce === "string") return mes.channel.send(akce);
|
||||||
const result = akce(celArgs, mes);
|
const result = akce(celArgs, mes);
|
||||||
if (!result || !result.then) mes.channel.send(result);
|
if (result && !result.then) mes.channel.send(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("debug", console.log);
|
client.on("debug", console.log);
|
||||||
|
|||||||
@ -16,7 +16,10 @@ module.exports = {
|
|||||||
|
|
||||||
kam: _ => mista[rand(mista.length)],
|
kam: _ => mista[rand(mista.length)],
|
||||||
|
|
||||||
je: _ => rand(2) ? "jo je" : "ne neni",
|
je: {
|
||||||
|
cd: 1800,
|
||||||
|
run: _ => rand(2) ? "jo je" : "ne neni"
|
||||||
|
},
|
||||||
|
|
||||||
ma: {
|
ma: {
|
||||||
als: ["má"],
|
als: ["má"],
|
||||||
@ -44,9 +47,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
jakmoc: arg => `${arg} na ${rand(101)}%`,
|
jakmoc: {
|
||||||
|
cd: 1800,
|
||||||
|
run: arg => `${arg} na ${rand(101)}%`
|
||||||
|
},
|
||||||
|
|
||||||
jakmoc0: arg => `${arg} na ${rand(1001)}%`,
|
|
||||||
|
jakmoc0: {
|
||||||
|
cd: 1800,
|
||||||
|
run: arg => `${arg} na ${rand(1001)}%`
|
||||||
|
},
|
||||||
|
|
||||||
uz: {
|
uz: {
|
||||||
als: ["už", "uz?", "už?"],
|
als: ["už", "uz?", "už?"],
|
||||||
|
|||||||
@ -69,27 +69,30 @@ module.exports = {
|
|||||||
|
|
||||||
wojs: (_, mes) => `vojs se pise s normalnim v ti kriple ${mes.author}`,
|
wojs: (_, mes) => `vojs se pise s normalnim v ti kriple ${mes.author}`,
|
||||||
|
|
||||||
vojs: (arg, mes) => {
|
vojs: {
|
||||||
const channel = mes.member.voice.channel;
|
cd: 1800,
|
||||||
if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`;
|
run: (arg, mes) => {
|
||||||
|
const channel = mes.member.voice.channel;
|
||||||
|
if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`;
|
||||||
|
|
||||||
if (arg !== 'potichu') mes.channel.send('<@&591306633196339261> vojs');
|
if (arg !== 'potichu') mes.channel.send('<@&591306633196339261> vojs');
|
||||||
|
|
||||||
if (mes.guild.voice?.channel === channel && mes.guild.connection) return;
|
if (mes.guild.voice?.channel === channel && mes.guild.connection) return;
|
||||||
|
|
||||||
channel.join()
|
channel.join()
|
||||||
.then(con => {
|
.then(con => {
|
||||||
if (!timeouty[mes.guild.id]) {
|
if (!timeouty[mes.guild.id]) {
|
||||||
vypocitatCas(con);
|
vypocitatCas(con);
|
||||||
con.on('disconnect', () => {
|
con.on('disconnect', () => {
|
||||||
if (timeouty[mes.guild.id]) {
|
if (timeouty[mes.guild.id]) {
|
||||||
clearTimeout(timeouty[mes.guild.id]);
|
clearTimeout(timeouty[mes.guild.id]);
|
||||||
delete timeouty[mes.guild.id];
|
delete timeouty[mes.guild.id];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setTimeout(() => con.play('./zvuky/nazdar.ogg'), 500);
|
setTimeout(() => con.play('./zvuky/nazdar.ogg'), 500);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
vypadni: {
|
vypadni: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user