mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
Фикс boosters если нет бустеров
Перенос функций в client.functions
This commit is contained in:
parent
37d95ed8ff
commit
4a7a5f500f
34 changed files with 143 additions and 176 deletions
60
base/JaBa.js
60
base/JaBa.js
|
@ -9,15 +9,7 @@ const BaseEvent = require("./BaseEvent.js"),
|
|||
BaseCommand = require("./BaseCommand.js"),
|
||||
path = require("path"),
|
||||
fs = require("fs").promises,
|
||||
mongoose = require("mongoose"),
|
||||
moment = require("moment");
|
||||
|
||||
moment.relativeTimeThreshold("ss", 5);
|
||||
moment.relativeTimeThreshold("s", 60);
|
||||
moment.relativeTimeThreshold("m", 60);
|
||||
moment.relativeTimeThreshold("h", 60);
|
||||
moment.relativeTimeThreshold("d", 24);
|
||||
moment.relativeTimeThreshold("M", 12);
|
||||
mongoose = require("mongoose");
|
||||
|
||||
class JaBa extends Client {
|
||||
constructor(options) {
|
||||
|
@ -249,56 +241,6 @@ class JaBa extends Client {
|
|||
return language(key, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Beautify date
|
||||
* @param {Date} date Date
|
||||
* @param {String | null} format Format for moment
|
||||
* @param {String} locale Language
|
||||
* @returns {String} Beautified date
|
||||
*/
|
||||
printDate(date, format = "", locale = this.defaultLanguage) {
|
||||
const languageData = this.languages.find(language => language.name === locale);
|
||||
if (format === "" || format === null) format = languageData.defaultMomentFormat;
|
||||
|
||||
return moment(new Date(date))
|
||||
.locale(languageData.moment)
|
||||
.format(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert given time
|
||||
* @param {String} time Time
|
||||
* @param {Boolean} type Type (To now = true or from now = false)
|
||||
* @param {Boolean} noPrefix Use prefix?
|
||||
* @param {String} locale Language
|
||||
* @returns {String} Time
|
||||
*/
|
||||
convertTime(time, type = false, noPrefix = false, locale = this.defaultLanguage) {
|
||||
const languageData = this.languages.find(language => language.name === locale);
|
||||
const m = moment(time).locale(languageData.moment);
|
||||
|
||||
return (type ? m.toNow(noPrefix) : m.fromNow(noPrefix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get noun for number
|
||||
* @param {Number} number Number
|
||||
* @param {String} one String for one
|
||||
* @param {String} two String for two
|
||||
* @param {String} five String for five
|
||||
* @returns
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find or create user in DB
|
||||
* @param {Array} param0 { id: User ID }
|
||||
|
|
|
@ -49,7 +49,7 @@ class Bank extends BaseCommand {
|
|||
if (choice === "deposit") {
|
||||
const credits = interaction.options.getString("credits") === "all" ? data.memberData.money : interaction.options.getString("credits");
|
||||
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
|
||||
if (data.memberData.money < credits) return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", { money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
|
||||
if (data.memberData.money < credits) return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
|
||||
|
||||
data.memberData.money -= credits;
|
||||
data.memberData.bankSold += credits;
|
||||
|
@ -64,12 +64,12 @@ class Bank extends BaseCommand {
|
|||
data.memberData.transactions.push(info);
|
||||
|
||||
interaction.success("economy/bank:SUCCESS_DEP", {
|
||||
money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
});
|
||||
} else {
|
||||
const credits = interaction.options.getString("credits") === "all" ? data.memberData.bankSold : interaction.options.getString("credits");
|
||||
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
|
||||
if (data.memberData.bankSold < credits) return interaction.error("economy/bank:NOT_ENOUGH_BANK", { money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
|
||||
if (data.memberData.bankSold < credits) return interaction.error("economy/bank:NOT_ENOUGH_BANK", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:BANK"),
|
||||
|
@ -85,7 +85,7 @@ class Bank extends BaseCommand {
|
|||
await data.memberData.save();
|
||||
|
||||
interaction.success("economy/bank:SUCCESS_WD", {
|
||||
money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class Birthdate extends BaseCommand {
|
|||
await data.userData.save();
|
||||
|
||||
interaction.success("economy/birthdate:SUCCESS", {
|
||||
date: client.printDate(d),
|
||||
date: client.functions.printDate(d),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -65,17 +65,17 @@ class Money extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: interaction.translate("economy/profile:CASH"),
|
||||
value: `**${memberData.money}** ${client.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
value: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:BANK"),
|
||||
value: `**${memberData.bankSold}** ${client.getNoun(memberData.bankSold, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
value: `**${memberData.bankSold}** ${client.functions.getNoun(memberData.bankSold, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:GLOBAL"),
|
||||
value: `**${globalMoney}** ${client.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
value: `**${globalMoney}** ${client.functions.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
])
|
||||
|
|
|
@ -57,7 +57,7 @@ class Number extends BaseCommand {
|
|||
const parsedNumber = parseInt(msg.content, 10);
|
||||
|
||||
if (parsedNumber === number) {
|
||||
const time = client.convertTime(gameCreatedAt, false, false, data.guildData.language);
|
||||
const time = client.functions.convertTime(gameCreatedAt, false, false, data.guildData.language);
|
||||
interaction.channel.send({
|
||||
content: interaction.translate("economy/number:GAME_STATS", {
|
||||
winner: msg.author.toString(),
|
||||
|
@ -74,7 +74,7 @@ class Number extends BaseCommand {
|
|||
interaction.channel.send({
|
||||
content: interaction.translate("economy/number:WON", {
|
||||
winner: msg.author.username,
|
||||
credits: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
credits: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class Pay extends BaseCommand {
|
|||
const amount = interaction.options.getInteger("amount");
|
||||
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
|
||||
if (amount > data.memberData.money) return interaction.error("economy/pay:ENOUGH_MONEY", {
|
||||
amount: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`,
|
||||
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`,
|
||||
});
|
||||
|
||||
const memberData = await client.findOrCreateMember({
|
||||
|
@ -79,7 +79,7 @@ class Pay extends BaseCommand {
|
|||
|
||||
interaction.success("economy/pay:SUCCESS", {
|
||||
user: member.toString(),
|
||||
amount: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,22 +79,22 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:CASH"),
|
||||
value: `**${memberData.money}** ${client.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
value: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:BANK"),
|
||||
value: `**${memberData.bankSold}** ${client.getNoun(memberData.bankSold, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
value: `**${memberData.bankSold}** ${client.functions.getNoun(memberData.bankSold, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:GLOBAL"),
|
||||
value: `**${globalMoney}** ${client.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
value: `**${globalMoney}** ${client.functions.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:REPUTATION"),
|
||||
value: `**${userData.rep}** ${client.getNoun(userData.rep, interaction.translate("misc:NOUNS:POINTS:1"), interaction.translate("misc:NOUNS:POINTS:2"), interaction.translate("misc:NOUNS:POINTS:5"))}`,
|
||||
value: `**${userData.rep}** ${client.functions.getNoun(userData.rep, interaction.translate("misc:NOUNS:POINTS:1"), interaction.translate("misc:NOUNS:POINTS:2"), interaction.translate("misc:NOUNS:POINTS:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
@ -109,12 +109,12 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:REGISTERED"),
|
||||
value: client.printDate(new Date(memberData.registeredAt)),
|
||||
value: client.functions.printDate(new Date(memberData.registeredAt)),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:BIRTHDATE"),
|
||||
value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.printDate(new Date(userData.birthdate))),
|
||||
value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(new Date(userData.birthdate))),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ class Rep extends BaseCommand {
|
|||
const isInCooldown = data.userData.cooldowns?.rep;
|
||||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/rep:COOLDOWN", {
|
||||
time: client.convertTime(isInCooldown, true, true, data.guildData.language),
|
||||
time: client.functions.convertTime(isInCooldown, true, true, data.guildData.language),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ class Rob extends BaseCommand {
|
|||
|
||||
const potentiallyLose = Math.floor(amount * 1.5);
|
||||
if (potentiallyLose > data.memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_AUTHOR", {
|
||||
moneyMin: `**${potentiallyLose}** ${client.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
moneyCurrent: `**${data.memberData.money}** ${client.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
moneyMin: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
moneyCurrent: `**${data.memberData.money}** ${client.functions.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
});
|
||||
|
||||
const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25);
|
||||
|
@ -75,7 +75,7 @@ class Rob extends BaseCommand {
|
|||
await memberData.save();
|
||||
|
||||
interaction.replyT("economy/rob:ROB_WON_" + randomNum, {
|
||||
money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
user: member.toString(),
|
||||
});
|
||||
|
||||
|
@ -89,8 +89,8 @@ class Rob extends BaseCommand {
|
|||
randomNum = client.functions.randomNum(1, 2);
|
||||
|
||||
interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, {
|
||||
fine: `**${potentiallyLose}** ${client.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
offset: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
fine: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
offset: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
user: member.toString(),
|
||||
});
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Slots extends BaseCommand {
|
|||
await interaction.deferReply();
|
||||
|
||||
const amount = interaction.options.getInteger("amount");
|
||||
if (amount > data.memberData.money) return interaction.error("economy/slots:NOT_ENOUGH", { money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` }, { edit: true });
|
||||
if (amount > data.memberData.money) return interaction.error("economy/slots:NOT_ENOUGH", { money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` }, { edit: true });
|
||||
|
||||
const fruits = ["🍎", "🍐", "🍌", "🍇", "🍉", "🍒", "🍓"];
|
||||
|
||||
|
@ -95,8 +95,8 @@ class Slots extends BaseCommand {
|
|||
const credits = getCredits(amount, true);
|
||||
interaction.followUp({
|
||||
content: "**!! ДЖЕКПОТ !!**\n" + interaction.translate("economy/slots:VICTORY", {
|
||||
money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
won: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
won: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
user: interaction.member.toString(),
|
||||
}),
|
||||
});
|
||||
|
@ -140,8 +140,8 @@ class Slots extends BaseCommand {
|
|||
const credits = getCredits(amount, false);
|
||||
interaction.followUp({
|
||||
content: interaction.translate("economy/slots:VICTORY", {
|
||||
money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
won: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
won: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
user: interaction.member.toString(),
|
||||
}),
|
||||
});
|
||||
|
@ -177,7 +177,7 @@ class Slots extends BaseCommand {
|
|||
msg += "| : : : **" + (interaction.translate("common:DEFEAT").toUpperCase()) + "** : : : |";
|
||||
interaction.followUp({
|
||||
content: interaction.translate("economy/slots:DEFEAT", {
|
||||
money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
user: interaction.member.toString(),
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -57,7 +57,7 @@ class Transactions extends BaseCommand {
|
|||
|
||||
transactions.slice(-20).forEach(t => {
|
||||
const array = t.type === "got" ? sortedTransactions[0] : sortedTransactions[1];
|
||||
array.push(`${interaction.translate("economy/transactions:T_USER_" + t.type.toUpperCase())}: ${t.user}\n${interaction.translate("economy/transactions:T_AMOUNT")}: ${t.amount}\n${interaction.translate("economy/transactions:T_DATE")}: ${client.printDate(t.date, "Do MMMM YYYY, HH:mm", data.guildData.language)}\n`);
|
||||
array.push(`${interaction.translate("economy/transactions:T_USER_" + t.type.toUpperCase())}: ${t.user}\n${interaction.translate("economy/transactions:T_AMOUNT")}: ${t.amount}\n${interaction.translate("economy/transactions:T_DATE")}: ${client.functions.printDate(t.date, "Do MMMM YYYY, HH:mm", data.guildData.language)}\n`);
|
||||
});
|
||||
|
||||
if (transactions.length < 1) {
|
||||
|
|
|
@ -35,7 +35,7 @@ class Work extends BaseCommand {
|
|||
const isInCooldown = data.memberData.cooldowns?.work;
|
||||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/work:COOLDOWN", {
|
||||
time: client.convertTime(isInCooldown, true, true, data.guildData.language),
|
||||
time: client.functions.convertTime(isInCooldown, true, true, data.guildData.language),
|
||||
});
|
||||
}
|
||||
if (Date.now() > data.memberData.cooldowns.work + (24 * 60 * 60 * 1000)) data.memberData.workStreak = 0;
|
||||
|
@ -69,7 +69,7 @@ class Work extends BaseCommand {
|
|||
{
|
||||
name: interaction.translate("economy/work:SALARY"),
|
||||
value: interaction.translate("economy/work:SALARY_CONTENT", {
|
||||
won: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
won: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ class Work extends BaseCommand {
|
|||
{
|
||||
name: interaction.translate("economy/work:SALARY"),
|
||||
value: interaction.translate("economy/work:SALARY_CONTENT", {
|
||||
won: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
won: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -36,7 +36,9 @@ class Boosters extends BaseCommand {
|
|||
|
||||
let currentPage = 0;
|
||||
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
|
||||
const embeds = generateBoostersEmbeds(interaction, boosters);
|
||||
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
|
||||
|
||||
const embeds = generateBoostersEmbeds(client, interaction, boosters);
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
|
@ -143,11 +145,12 @@ class Boosters extends BaseCommand {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Array} boosters
|
||||
* @returns
|
||||
*/
|
||||
function generateBoostersEmbeds(interaction, boosters) {
|
||||
function generateBoostersEmbeds(client, interaction, boosters) {
|
||||
const embeds = [];
|
||||
let k = 10;
|
||||
|
||||
|
@ -156,7 +159,7 @@ function generateBoostersEmbeds(interaction, boosters) {
|
|||
let j = i;
|
||||
k += 10;
|
||||
|
||||
const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${interaction.client.printDate(member.premiumSince, null, interaction.guild.data.locale)}**`).join("\n");
|
||||
const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(member.premiumSince, null, interaction.guild.data.locale)}**`).join("\n");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(interaction.client.config.embed.color)
|
||||
|
|
|
@ -71,7 +71,7 @@ class Minecraft extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("general/minecraft:FIELD_CONNECTED"),
|
||||
value: `**${(res.raw.players ? res.raw.players.online : res.players.length)}** ${client.getNoun((res.raw.players ? res.raw.players.online : res.players.length), interaction.translate("misc:NOUNS:PLAYERS:1"), interaction.translate("misc:NOUNS:PLAYERS:2"), interaction.translate("misc:NOUNS:PLAYERS:5"))} / **${(res.raw.players ? res.raw.players.max : res.maxplayers)}** ${client.getNoun((res.raw.players ? res.raw.players.max : res.maxplayers), interaction.translate("misc:NOUNS:PLAYERS:1"), interaction.translate("misc:NOUNS:PLAYERS:2"), interaction.translate("misc:NOUNS:PLAYERS:5"))}`,
|
||||
value: `**${(res.raw.players ? res.raw.players.online : res.players.length)}** ${client.functions.getNoun((res.raw.players ? res.raw.players.online : res.players.length), interaction.translate("misc:NOUNS:PLAYERS:1"), interaction.translate("misc:NOUNS:PLAYERS:2"), interaction.translate("misc:NOUNS:PLAYERS:5"))} / **${(res.raw.players ? res.raw.players.max : res.maxplayers)}** ${client.functions.getNoun((res.raw.players ? res.raw.players.max : res.maxplayers), interaction.translate("misc:NOUNS:PLAYERS:1"), interaction.translate("misc:NOUNS:PLAYERS:2"), interaction.translate("misc:NOUNS:PLAYERS:5"))}`,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("general/minecraft:FIELD_IP"),
|
||||
|
|
|
@ -59,7 +59,7 @@ class Report extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: interaction.translate("common:DATE"),
|
||||
value: client.printDate(new Date(Date.now())),
|
||||
value: client.functions.printDate(new Date(Date.now())),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:AUTHOR"),
|
||||
|
|
|
@ -55,13 +55,13 @@ class Serverinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.calendar + interaction.translate("common:CREATION"),
|
||||
value: client.printDate(guild.createdAt),
|
||||
value: client.functions.printDate(guild.createdAt),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.users + interaction.translate("common:MEMBERS"),
|
||||
value: `${guild.members.cache.filter(m => !m.user.bot).size} ${client.getNoun(guild.members.cache.filter(m => !m.user.bot).size, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}` +
|
||||
"\n" + `${guild.members.cache.filter(m => m.user.bot).size} ${client.getNoun(guild.members.cache.filter(m => m.user.bot).size, interaction.translate("misc:NOUNS:BOTS:1"), interaction.translate("misc:NOUNS:BOTS:2"), interaction.translate("misc:NOUNS:BOTS:5"))}`,
|
||||
value: `${guild.members.cache.filter(m => !m.user.bot).size} ${client.functions.getNoun(guild.members.cache.filter(m => !m.user.bot).size, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}` +
|
||||
"\n" + `${guild.members.cache.filter(m => m.user.bot).size} ${client.functions.getNoun(guild.members.cache.filter(m => m.user.bot).size, interaction.translate("misc:NOUNS:BOTS:1"), interaction.translate("misc:NOUNS:BOTS:2"), interaction.translate("misc:NOUNS:BOTS:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
@ -86,9 +86,9 @@ class Serverinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.channels + interaction.translate("common:CHANNELS"),
|
||||
value: `${guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size} ${client.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size, interaction.translate("misc:NOUNS:TEXT:1"), interaction.translate("misc:NOUNS:TEXT:2"), interaction.translate("misc:NOUNS:TEXT:5"))}` +
|
||||
"\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size} ${client.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size, interaction.translate("misc:NOUNS:VOICE:1"), interaction.translate("misc:NOUNS:VOICE:2"), interaction.translate("misc:NOUNS:VOICE:5"))}` +
|
||||
"\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size} ${client.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size, interaction.translate("misc:NOUNS:CATEGORY:1"), interaction.translate("misc:NOUNS:CATEGORY:2"), interaction.translate("misc:NOUNS:CATEGORY:5"))}`,
|
||||
value: `${guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size} ${client.functions.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size, interaction.translate("misc:NOUNS:TEXT:1"), interaction.translate("misc:NOUNS:TEXT:2"), interaction.translate("misc:NOUNS:TEXT:5"))}` +
|
||||
"\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size} ${client.functions.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size, interaction.translate("misc:NOUNS:VOICE:1"), interaction.translate("misc:NOUNS:VOICE:2"), interaction.translate("misc:NOUNS:VOICE:5"))}` +
|
||||
"\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size} ${client.functions.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size, interaction.translate("misc:NOUNS:CATEGORY:1"), interaction.translate("misc:NOUNS:CATEGORY:2"), interaction.translate("misc:NOUNS:CATEGORY:5"))}`,
|
||||
inline: true,
|
||||
},
|
||||
])
|
||||
|
|
|
@ -70,13 +70,13 @@ class Stats extends BaseCommand {
|
|||
{
|
||||
name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"),
|
||||
value: interaction.translate("general/stats:ONLINE_CONTENT", {
|
||||
time: client.convertTime(Date.now() + client.uptime, true, true, data.guildData.language),
|
||||
time: client.functions.convertTime(Date.now() + client.uptime, true, true, data.guildData.language),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.voice + " " + interaction.translate("general/stats:MUSIC_TITLE"),
|
||||
value: interaction.translate("general/stats:MUSIC_CONTENT", {
|
||||
count: `${client.player.queues.size} ${client.getNoun(client.player.queues.size, interaction.translate("misc:NOUNS:SERVERS:1"), interaction.translate("misc:NOUNS:SERVERS:2"), interaction.translate("misc:NOUNS:SERVERS:5"))}`,
|
||||
count: `${client.player.queues.size} ${client.functions.getNoun(client.player.queues.size, interaction.translate("misc:NOUNS:SERVERS:1"), interaction.translate("misc:NOUNS:SERVERS:2"), interaction.translate("misc:NOUNS:SERVERS:5"))}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ class Suggest extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: interaction.translate("common:DATE"),
|
||||
value: client.printDate(new Date(Date.now())),
|
||||
value: client.functions.printDate(new Date(Date.now())),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:AUTHOR"),
|
||||
|
|
|
@ -67,12 +67,12 @@ class Userinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.calendar + " " + interaction.translate("common:CREATION"),
|
||||
value: client.printDate(member.user.createdAt),
|
||||
value: client.functions.printDate(member.user.createdAt),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"),
|
||||
value: client.printDate(member.joinedAt),
|
||||
value: client.functions.printDate(member.joinedAt),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -124,12 +124,12 @@ class Clear extends BaseCommand {
|
|||
|
||||
if (member || user_id) {
|
||||
interaction.replyT("moderation/clear:CLEARED_MEMBER", {
|
||||
amount: `**${option}** ${client.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`,
|
||||
amount: `**${option}** ${client.functions.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`,
|
||||
user: (member?.user.tag || user_id),
|
||||
}, { edit: true });
|
||||
} else {
|
||||
interaction.replyT("moderation/clear:CLEARED", {
|
||||
amount: `**${option}** ${client.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`,
|
||||
amount: `**${option}** ${client.functions.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`,
|
||||
}, { edit: true });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ class Warn extends BaseCommand {
|
|||
interaction.followUp({
|
||||
content: interaction.translate("moderation/setwarns:AUTO_BAN", {
|
||||
user: member.user.tag,
|
||||
count: `${banCount} ${client.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
||||
count: `${banCount} ${client.functions.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class Warn extends BaseCommand {
|
|||
interaction.followUp({
|
||||
content: interaction.translate("moderation/setwarns:AUTO_KICK", {
|
||||
user: member.user.tag,
|
||||
count: `${kickCount} ${client.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
||||
count: `${kickCount} ${client.functions.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ function generateQueueEmbeds(interaction, queue) {
|
|||
queue.repeatMode === QueueRepeatMode.AUTOPLAY ? interaction.translate("music/nowplaying:AUTOPLAY") :
|
||||
queue.repeatMode === QueueRepeatMode.QUEUE ? interaction.translate("music/nowplaying:QUEUE") :
|
||||
queue.repeatMode === QueueRepeatMode.TRACK ? interaction.translate("music/nowplaying:TRACK") : interaction.translate("common:DISABLED")
|
||||
}\`\n${interaction.translate("music/queue:DURATION")}: \`${interaction.client.convertTime(Date.now() + queue.totalTime, false, true, interaction.guild.data.language)}\`\n[${currentTrack.title}](${currentTrack.url})\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${interaction.translate("music/queue:NO_QUEUE")}`)
|
||||
}\`\n${interaction.translate("music/queue:DURATION")}: \`${interaction.client.functions.convertTime(Date.now() + queue.totalTime, false, true, interaction.guild.data.language)}\`\n[${currentTrack.title}](${currentTrack.url})\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${interaction.translate("music/queue:NO_QUEUE")}`)
|
||||
.setTimestamp();
|
||||
embeds.push(embed);
|
||||
|
||||
|
@ -191,7 +191,7 @@ function generateQueueEmbeds(interaction, queue) {
|
|||
queue.repeatMode === QueueRepeatMode.AUTOPLAY ? interaction.translate("music/nowplaying:AUTOPLAY") :
|
||||
queue.repeatMode === QueueRepeatMode.QUEUE ? interaction.translate("music/nowplaying:QUEUE") :
|
||||
queue.repeatMode === QueueRepeatMode.TRACK ? interaction.translate("music/nowplaying:TRACK") : interaction.translate("common:DISABLED")
|
||||
}\`\n${interaction.translate("music/queue:DURATION")}: \`${interaction.client.convertTime(Date.now() + queue.node.streamTime, false, true, interaction.guild.data.language)}\`\n[${currentTrack.title}](${currentTrack.url})\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${info}`)
|
||||
}\`\n${interaction.translate("music/queue:DURATION")}: \`${interaction.client.functions.convertTime(Date.now() + queue.node.streamTime, false, true, interaction.guild.data.language)}\`\n[${currentTrack.title}](${currentTrack.url})\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${info}`)
|
||||
.setTimestamp();
|
||||
embeds.push(embed);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class Seek extends BaseCommand {
|
|||
|
||||
queue.node.seek(time * 1000);
|
||||
interaction.success("music/seek:SUCCESS", {
|
||||
time: `**${time}** ${client.getNoun(time, interaction.translate("misc:NOUNS:SECONDS:1"), interaction.translate("misc:NOUNS:SECONDS:2"), interaction.translate("misc:NOUNS:SECONDS:5"))}`,
|
||||
time: `**${time}** ${client.functions.getNoun(time, interaction.translate("misc:NOUNS:SECONDS:1"), interaction.translate("misc:NOUNS:SECONDS:2"), interaction.translate("misc:NOUNS:SECONDS:5"))}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,6 @@ class Servers extends BaseCommand {
|
|||
.setCustomId("servers_next_page")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setEmoji("➡️"),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("servers_jump_page")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setEmoji("↗️"),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("servers_stop")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
|
@ -90,37 +86,6 @@ class Servers extends BaseCommand {
|
|||
components: [row],
|
||||
});
|
||||
}
|
||||
} else if (i.customId === "servers_jump_page") {
|
||||
i.deferUpdate();
|
||||
|
||||
const msg = await interaction.followUp({
|
||||
content: interaction.translate("misc:JUMP_TO_PAGE", {
|
||||
length: embeds.length,
|
||||
}),
|
||||
fetchReply: true,
|
||||
});
|
||||
|
||||
const filter = res => {
|
||||
return res.author.id === interaction.user.id && !isNaN(res.content);
|
||||
};
|
||||
|
||||
interaction.channel.awaitMessages({ filter, max: 1, time: (10 * 1000) }).then(collected => {
|
||||
if (embeds[collected.first().content - 1]) {
|
||||
currentPage = collected.first().content - 1;
|
||||
interaction.editReply({
|
||||
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
|
||||
embeds: [embeds[currentPage]],
|
||||
components: [row],
|
||||
});
|
||||
|
||||
if (collected.first().deletable) collected.first().delete();
|
||||
if (msg.deletable) msg.delete();
|
||||
} else {
|
||||
if (collected.first().deletable) collected.first().delete();
|
||||
if (msg.deletable) msg.delete();
|
||||
return;
|
||||
}
|
||||
});
|
||||
} else if (i.customId === "servers_stop") {
|
||||
i.deferUpdate();
|
||||
collector.stop();
|
||||
|
@ -155,7 +120,7 @@ function generateServersEmbeds(interaction, servers) {
|
|||
let j = i;
|
||||
k += 10;
|
||||
|
||||
const info = current.map(server => `${++j}. ${server.name} | ${server.memberCount} ${interaction.client.getNoun(server.memberCount, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}`).join("\n");
|
||||
const info = current.map(server => `${++j}. ${server.name} | ${server.memberCount} ${interaction.client.functions.getNoun(server.memberCount, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}`).join("\n");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(interaction.client.config.embed.color)
|
||||
|
|
|
@ -43,8 +43,8 @@ module.exports.init = async(client) => {
|
|||
if (req.user && req.url !== "/") req.userInfos = await utils.fetchUser(req.user, req.client);
|
||||
if (req.user) {
|
||||
req.translate = req.client.translations.get(req.locale);
|
||||
req.printDate = (date) => req.client.printDate(date, null, req.locale);
|
||||
req.convertTime = (time) => req.client.convertTime(time, "to", true, req.locale);
|
||||
req.printDate = (date) => req.client.functions.printDate(date, null, req.locale);
|
||||
req.convertTime = (time) => req.client.functions.convertTime(time, "to", true, req.locale);
|
||||
}
|
||||
next();
|
||||
})
|
||||
|
|
|
@ -55,7 +55,7 @@ class GuildCreate extends BaseEvent {
|
|||
iconURL: guild.iconURL(),
|
||||
})
|
||||
.setColor("#32CD32")
|
||||
.setDescription(`Зашёл на сервер **${guild.name}**. На нём **${users}** ${client.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))} и **${bots}** ${client.getNoun(bots, client.translate("misc:NOUNS:BOTS:1"), client.translate("misc:NOUNS:BOTS:2"), client.translate("misc:NOUNS:BOTS:5"))}`);
|
||||
.setDescription(`Зашёл на сервер **${guild.name}**. На нём **${users}** ${client.functions.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))} и **${bots}** ${client.functions.getNoun(bots, client.translate("misc:NOUNS:BOTS:1"), client.translate("misc:NOUNS:BOTS:2"), client.translate("misc:NOUNS:BOTS:5"))}`);
|
||||
client.channels.cache.get(client.config.support.logs).send({
|
||||
embeds: [embed],
|
||||
});
|
||||
|
|
|
@ -90,7 +90,7 @@ class GuildMemberRemove extends BaseEvent {
|
|||
|
||||
// Draw membercount
|
||||
ctx.font = "22px RubikMonoOne";
|
||||
ctx.fillText(`${member.guild.memberCount} ${client.getNoun(member.guild.memberCount, client.translate("misc:NOUNS:MEMBERS:1", null, member.guild.data.language), client.translate("misc:NOUNS:MEMBERS:2", null, member.guild.data.language), client.translate("misc:NOUNS:MEMBERS:5", null, member.guild.data.language))}`, 40, canvas.height - 35);
|
||||
ctx.fillText(`${member.guild.memberCount} ${client.functions.getNoun(member.guild.memberCount, client.translate("misc:NOUNS:MEMBERS:1", null, member.guild.data.language), client.translate("misc:NOUNS:MEMBERS:2", null, member.guild.data.language), client.translate("misc:NOUNS:MEMBERS:5", null, member.guild.data.language))}`, 40, canvas.height - 35);
|
||||
|
||||
// Draw # for discriminator
|
||||
ctx.fillStyle = "#FFFFFF";
|
||||
|
|
|
@ -37,17 +37,14 @@ class Ready extends BaseEvent {
|
|||
const checkReminds = require("../helpers/checkReminds");
|
||||
checkReminds.init(client);
|
||||
|
||||
const cleanup = require("../helpers/cleanup");
|
||||
cleanup.init(client);
|
||||
|
||||
if (client.config.dashboard.enabled) client.dashboard.init(client);
|
||||
|
||||
const version = require("../package.json").version;
|
||||
const status = [
|
||||
{ name: "help", type: ActivityType.Watching },
|
||||
{ name: `${commands.length} ${client.getNoun(commands.length, client.translate("misc:NOUNS:COMMANDS:1"), client.translate("misc:NOUNS:COMMANDS:2"), client.translate("misc:NOUNS:COMMANDS:5"))}`, type: ActivityType.Listening },
|
||||
{ name: `${tServers} ${client.getNoun(tServers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}`, type: ActivityType.Watching },
|
||||
{ name: `${tUsers} ${client.getNoun(tUsers, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}`, type: ActivityType.Watching },
|
||||
{ name: `${commands.length} ${client.functions.getNoun(commands.length, client.translate("misc:NOUNS:COMMANDS:1"), client.translate("misc:NOUNS:COMMANDS:2"), client.translate("misc:NOUNS:COMMANDS:5"))}`, type: ActivityType.Listening },
|
||||
{ name: `${tServers} ${client.functions.getNoun(tServers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}`, type: ActivityType.Watching },
|
||||
{ name: `${tUsers} ${client.functions.getNoun(tUsers, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}`, type: ActivityType.Watching },
|
||||
];
|
||||
|
||||
let i = 0;
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports.update = function (client) {
|
|||
if (!categories.includes(cmd.category)) categories.push(cmd.category);
|
||||
});
|
||||
|
||||
let text = `# JaBa имеет **${commands.length} ${client.getNoun(commands.length, "команда", "команды", "команд")}** в **${categories.length} ${client.getNoun(categories.length, "категории", "категориях", "категориях")}**! \n\n#### Содержимое таблицы \n**Название**: Название команды \n**Описание**: Описание команды \n**Использование**: Использование команды ( [] - обязательно, () - необязательно ) \n**Разрешено использование**: Где можно использовать команду \n\n`;
|
||||
let text = `# JaBa имеет **${commands.length} ${client.functions.getNoun(commands.length, "команда", "команды", "команд")}** в **${categories.length} ${client.functions.getNoun(categories.length, "категории", "категориях", "категориях")}**! \n\n#### Содержимое таблицы \n**Название**: Название команды \n**Описание**: Описание команды \n**Использование**: Использование команды ( [] - обязательно, () - необязательно ) \n**Разрешено использование**: Где можно использовать команду \n\n`;
|
||||
|
||||
// categories.sort(function(a, b) {
|
||||
// const aCmdsSize = commands.filter(cmd => cmd.category === a).size;
|
||||
|
@ -29,7 +29,7 @@ module.exports.update = function (client) {
|
|||
];
|
||||
const cmds = [...new Map(commands.filter(cmd => cmd.category === cat).map(v => [v.constructor.name, v])).values()];
|
||||
|
||||
text += `### ${cat} (${cmds.length} ${client.getNoun(cmds.length, "команда", "команды", "команд")})\n\n`;
|
||||
text += `### ${cat} (${cmds.length} ${client.functions.getNoun(cmds.length, "команда", "команды", "команд")})\n\n`;
|
||||
cmds.sort(function (a, b) {
|
||||
if (a.command.name < b.command.name) return -1;
|
||||
else return 1;
|
||||
|
|
|
@ -49,7 +49,7 @@ module.exports.init = async function (client) {
|
|||
value: client.translate("economy/birthdate:HAPPY_BIRTHDAY_MESSAGE", {
|
||||
name: user.username,
|
||||
user: user.id,
|
||||
age: `**${age}** ${client.getNoun(age, client.translate("misc:NOUNS:AGE:1"), client.translate("misc:NOUNS:AGE:2"), client.translate("misc:NOUNS:AGE:5"))}`,
|
||||
age: `**${age}** ${client.functions.getNoun(age, client.translate("misc:NOUNS:AGE:1"), client.translate("misc:NOUNS:AGE:2"), client.translate("misc:NOUNS:AGE:5"))}`,
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -15,14 +15,14 @@ BaseInteraction.prototype.replyT = function (key, args, options = {}) {
|
|||
else return this.reply({ content: string, ephemeral: options.ephemeral || false });
|
||||
};
|
||||
|
||||
BaseInteraction.prototype.error = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "error";
|
||||
BaseInteraction.prototype.success = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "success";
|
||||
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
||||
BaseInteraction.prototype.success = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "success";
|
||||
BaseInteraction.prototype.error = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "error";
|
||||
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
@ -42,14 +42,14 @@ Message.prototype.replyT = function (key, args, options = {}) {
|
|||
else return this.reply({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } });
|
||||
};
|
||||
|
||||
Message.prototype.error = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "error";
|
||||
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
||||
Message.prototype.success = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "success";
|
||||
|
||||
return this.replyT(key, args, options);
|
||||
};
|
||||
|
||||
Message.prototype.error = function (key, args, options = {}) {
|
||||
options.prefixEmoji = "error";
|
||||
|
||||
return this.replyT(key, args, options);
|
||||
};
|
|
@ -1,4 +1,12 @@
|
|||
const { PermissionsBitField, ChannelType } = require("discord.js");
|
||||
const moment = require("moment");
|
||||
|
||||
moment.relativeTimeThreshold("ss", 5);
|
||||
moment.relativeTimeThreshold("s", 60);
|
||||
moment.relativeTimeThreshold("m", 60);
|
||||
moment.relativeTimeThreshold("h", 60);
|
||||
moment.relativeTimeThreshold("d", 24);
|
||||
moment.relativeTimeThreshold("M", 12);
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
|
@ -20,7 +28,7 @@ module.exports = {
|
|||
* @param {Function} callback
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async asyncForEach (collection, callback) {
|
||||
async asyncForEach(collection, callback) {
|
||||
const allPromises = collection.map(async key => {
|
||||
await callback(key);
|
||||
});
|
||||
|
@ -77,4 +85,54 @@ module.exports = {
|
|||
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
},
|
||||
|
||||
/**
|
||||
* Beautify date
|
||||
* @param {Date} date Date
|
||||
* @param {String | null} format Format for moment
|
||||
* @param {String} locale Language
|
||||
* @returns {String} Beautified date
|
||||
*/
|
||||
printDate(date, format = "", locale = this.defaultLanguage) {
|
||||
const languageData = this.languages.find(language => language.name === locale);
|
||||
if (format === "" || format === null) format = languageData.defaultMomentFormat;
|
||||
|
||||
return moment(new Date(date))
|
||||
.locale(languageData.moment)
|
||||
.format(format);
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert given time
|
||||
* @param {String} time Time
|
||||
* @param {Boolean} type Type (To now = true or from now = false)
|
||||
* @param {Boolean} noPrefix Use prefix?
|
||||
* @param {String} locale Language
|
||||
* @returns {String} Time
|
||||
*/
|
||||
convertTime(time, type = false, noPrefix = false, locale = this.defaultLanguage) {
|
||||
const languageData = this.languages.find(language => language.name === locale);
|
||||
const m = moment(time).locale(languageData.moment);
|
||||
|
||||
return (type ? m.toNow(noPrefix) : m.fromNow(noPrefix));
|
||||
},
|
||||
|
||||
/**
|
||||
* Get noun for number
|
||||
* @param {Number} number Number
|
||||
* @param {String} one String for one
|
||||
* @param {String} two String for two
|
||||
* @param {String} five String for five
|
||||
* @returns
|
||||
*/
|
||||
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;
|
||||
},
|
||||
};
|
|
@ -3,5 +3,6 @@
|
|||
"USAGE": "",
|
||||
"EXAMPLES": "boosters",
|
||||
"BOOSTERS_LIST": "Список бустеров",
|
||||
"NO_BOOSTERS": "Бусты отсутствуют",
|
||||
"BOOSTER_SINCE": "Буст с"
|
||||
}
|
|
@ -3,5 +3,6 @@
|
|||
"USAGE": "",
|
||||
"EXAMPLES": "boosters",
|
||||
"BOOSTERS_LIST": "Список бустерів",
|
||||
"NO_BOOSTERS": "Бусти відсутні",
|
||||
"BOOSTER_SINCE": "Буст з"
|
||||
}
|
Loading…
Reference in a new issue