const fs = require("fs");
let test = require("../test.json");
let talkedRecently = 0;
let talkedRecentlyDAYS = 0;
let talkedRecentlyHOURS = 0;
let talkedRecentlyMINUTES = 0;
let talkedRecentlySECUNDES = 0;
//@Den18, ку, сделай просто через JSON файл
if(message.content.startsWith(prefix + "day")) {
if(!test[message.author.id]) {
test[message.author.id] = {
time_wait:0,
}}
if (test[message.author.id].time_wait > 0) {
message.channel.send(`Вы уже использовали эту команду. Повторите через ${Math.floor(talkedRecentlyDAYS)} дней / ${Math.floor(talkedRecentlyHOURS)} часов / ${Math.floor(talkedRecentlyMINUTES)} минут / ${Math.floor(talkedRecentlySECUNDES)} секунд.`) //дней, часов, минут, секунд"
} else {
message.channel.send("Успешно!")
talkedRecently = 123123124124123;
test[message.author.id].time_wait = talkedRecently;
talkedRecentlySECUNDES = talkedRecently/1000;
talkedRecentlyMINUTES = talkedRecentlySECUNDES/60;
talkedRecentlyMINUTES = Math.floor(talkedRecentlyMINUTES)
talkedRecentlySECUNDES = talkedRecentlySECUNDES-talkedRecentlyMINUTES*60
talkedRecentlyHOURS = talkedRecentlyMINUTES/60
talkedRecentlyHOURS = Math.floor(talkedRecentlyHOURS)
talkedRecentlyMINUTES = talkedRecentlyMINUTES-talkedRecentlyHOURS*60
talkedRecentlyDAYS = talkedRecentlyHOURS/24
talkedRecentlyDAYS = Math.floor(talkedRecentlyDAYS)
talkedRecentlyHOURS = talkedRecentlyHOURS-talkedRecentlyDAYS*24
let time = setInterval(() => {
console.log(test[message.author.id].time_wait)
fs.writeFile('../test.json',JSON.stringify(test, null, 4),(err)=>{
if(err) console.log(err);
})
if (test[message.author.id].time_wait <= 0) { clearInterval(time); return; }
talkedRecentlySECUNDES -= 1;
if (talkedRecentlySECUNDES < 0) { talkedRecentlySECUNDES = 59; talkedRecentlyMINUTES -= 1; }
if (talkedRecentlyMINUTES < 0) { talkedRecentlyMINUTES = 59; talkedRecentlyHOURS -= 1; }
if (talkedRecentlyHOURS < 0) { talkedRecentlyHOURS = 23; talkedRecentlyDAYS -= 1; }
test[message.author.id].time_wait -= 1000;
}, 1000);
}
}
@Den18, let talkedRecently = 0;
let talkedRecentlyDAYS = 0;
let talkedRecentlyHOURS = 0;
let talkedRecentlyMINUTES = 0;
let talkedRecentlySECUNDES = 0;
if(message.content.startsWith(prefix + "day")) {
if (talkedRecently > 0) {
message.channel.send(`Вы уже использовали эту команду. Повторите через ${Math.floor(talkedRecentlyDAYS)} дней / ${Math.floor(talkedRecentlyHOURS)} часов / ${Math.floor(talkedRecentlyMINUTES)} минут / ${Math.floor(talkedRecentlySECUNDES)} секунд.`)
} else {
message.channel.send("Успешно!")
talkedRecently = 286400000; // например 286400000
talkedRecentlySECUNDES = talkedRecently/1000;
talkedRecentlyMINUTES = talkedRecentlySECUNDES/60;
talkedRecentlyMINUTES = Math.floor(talkedRecentlyMINUTES)
talkedRecentlySECUNDES = talkedRecentlySECUNDES-talkedRecentlyMINUTES*60
talkedRecentlyHOURS = talkedRecentlyMINUTES/60
talkedRecentlyHOURS = Math.floor(talkedRecentlyHOURS)
talkedRecentlyMINUTES = talkedRecentlyMINUTES-talkedRecentlyHOURS*60
talkedRecentlyDAYS = talkedRecentlyHOURS/24
talkedRecentlyDAYS = Math.floor(talkedRecentlyDAYS)
talkedRecentlyHOURS = talkedRecentlyHOURS-talkedRecentlyDAYS*24
let time = setInterval(() => {
if (talkedRecently == 0) { clearInterval(time); return; }
talkedRecentlySECUNDES -= 1;
if (talkedRecentlySECUNDES < 0) { talkedRecentlySECUNDES = 59; talkedRecentlyMINUTES -= 1; }
if (talkedRecentlyMINUTES < 0) { talkedRecentlyMINUTES = 59; talkedRecentlyHOURS -= 1; }
if (talkedRecentlyHOURS < 0) { talkedRecentlyHOURS = 23; talkedRecentlyDAYS -= 1; }
talkedRecently -= 1000;
}, 1000);
}
}