Склонения и 12 часов в work

This commit is contained in:
JonnyBro 2021-12-18 19:15:16 +05:00
parent 3c3802c293
commit 563c668562
3 changed files with 15 additions and 4 deletions

View file

@ -30,7 +30,7 @@ class Work extends Command {
if (Date.now() > data.memberData.cooldowns.work + (24 * 3600000)) data.memberData.workStreak = 0; if (Date.now() > data.memberData.cooldowns.work + (24 * 3600000)) data.memberData.workStreak = 0;
// Records in the database the time when the member will be able to execute the command again (in 12 hours) // Records in the database the time when the member will be able to execute the command again (in 12 hours)
const toWait = Date.now() + 21600000; const toWait = Date.now() + 43200000;
data.memberData.cooldowns.work = toWait; data.memberData.cooldowns.work = toWait;
data.memberData.markModified("cooldowns"); data.memberData.markModified("cooldowns");

View file

@ -38,7 +38,7 @@ module.exports = class {
// Update status every 20s // Update status every 20s
let servers = client.guilds.cache.filter(guild => guild.id != "568120814776614924" && guild.id != "892727526911258654").size; let servers = client.guilds.cache.filter(guild => guild.id != "568120814776614924" && guild.id != "892727526911258654").size;
const status = [ const status = [
{ name: `${servers} ${getNoun(`${servers}`, "сервер", "сервера", "серверов")}`, type: "WATCHING" }, { name: `${servers} ${getNoun(servers, "сервер", "сервера", "серверов")}`, type: "WATCHING" },
{ name: "help", type: "WATCHING" } { name: "help", type: "WATCHING" }
]; ];
const version = require("../package.json").version; const version = require("../package.json").version;

View file

@ -24,7 +24,7 @@ module.exports = {
[ "Название", "Описание", "Использование", "Откат" ] [ "Название", "Описание", "Использование", "Откат" ]
]; ];
const cmds = commands.filter((cmd) => cmd.help.category === cat).array(); const cmds = commands.filter((cmd) => cmd.help.category === cat).array();
text += `### ${cat} (${cmds.length} команд(а/ы))\n\n`; text += `### ${cat} (${cmds.length} ${getNoun(cmds.length, "команда", "команды", "команд")}команд(а/ы))\n\n`;
cmds.sort(function(a, b) { cmds.sort(function(a, b) {
if (a.help.name < b.help.name) return -1; if (a.help.name < b.help.name) return -1;
else return 1; else return 1;
@ -33,7 +33,7 @@ module.exports = {
`**${cmd.help.name}** ${cmd.help.aliases.length ? `**(${cmd.help.aliases.join(", ")})**` : ""}`, `**${cmd.help.name}** ${cmd.help.aliases.length ? `**(${cmd.help.aliases.join(", ")})**` : ""}`,
client.translate(`${cmd.help.category.toLowerCase()}/${cmd.help.name}:DESCRIPTION`), client.translate(`${cmd.help.category.toLowerCase()}/${cmd.help.name}:DESCRIPTION`),
client.translate(`${cmd.help.category.toLowerCase()}/${cmd.help.name}:USAGE`), client.translate(`${cmd.help.category.toLowerCase()}/${cmd.help.name}:USAGE`),
Math.ceil(cmd.conf.cooldown / 1000)+" секунд(а/ы)" `${Math.ceil(cmd.conf.cooldown / 1000)} ${getNoun(cmds.length, "секунда", "секунды", "секунд")}`
]); ]);
}); });
text += `${table(arrCat)}\n\n`; text += `${table(arrCat)}\n\n`;
@ -58,3 +58,14 @@ module.exports = {
}; };
} }
}; };
function getNoun(number, one, two, five) {
let n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) return five;
n %= 10;
if (n === 1) return one;
if (n >= 2 && n <= 4) return two;
return five;
};