mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
fix many commands
This commit is contained in:
parent
940532bcba
commit
4392b6e3a7
14 changed files with 22 additions and 20 deletions
|
@ -72,7 +72,7 @@ class Birthdate extends BaseCommand {
|
|||
await data.userData.save();
|
||||
|
||||
interaction.success("economy/birthdate:SUCCESS", {
|
||||
date: client.functions.printDate(d),
|
||||
date: client.functions.printDate(client, d),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class Number extends BaseCommand {
|
|||
const parsedNumber = parseInt(msg.content, 10);
|
||||
|
||||
if (parsedNumber === number) {
|
||||
const time = client.functions.convertTime(gameCreatedAt, false, false, data.guildData.language);
|
||||
const time = client.functions.convertTime(client, gameCreatedAt, false, false, data.guildData.language);
|
||||
interaction.channel.send({
|
||||
content: interaction.translate("economy/number:GAME_STATS", {
|
||||
winner: msg.author.toString(),
|
||||
|
|
|
@ -109,12 +109,12 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:REGISTERED"),
|
||||
value: client.functions.printDate(new Date(memberData.registeredAt)),
|
||||
value: client.functions.printDate(client, new Date(memberData.registeredAt)),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:BIRTHDATE"),
|
||||
value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(new Date(userData.birthdate))),
|
||||
value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(client, 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.functions.convertTime(isInCooldown, true, true, data.guildData.language),
|
||||
time: client.functions.convertTime(client, isInCooldown, true, true, data.guildData.language),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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.functions.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(client, 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.functions.convertTime(isInCooldown, true, true, data.guildData.language),
|
||||
time: client.functions.convertTime(client, isInCooldown, true, true, data.guildData.language),
|
||||
});
|
||||
}
|
||||
if (Date.now() > data.memberData.cooldowns.work + (24 * 60 * 60 * 1000)) data.memberData.workStreak = 0;
|
||||
|
|
|
@ -159,7 +159,7 @@ function generateBoostersEmbeds(client, interaction, boosters) {
|
|||
let j = i;
|
||||
k += 10;
|
||||
|
||||
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 info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(client, member.premiumSince, null, interaction.guild.data.locale)}**`).join("\n");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(interaction.client.config.embed.color)
|
||||
|
|
|
@ -59,7 +59,7 @@ class Report extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: interaction.translate("common:DATE"),
|
||||
value: client.functions.printDate(new Date(Date.now())),
|
||||
value: client.functions.printDate(client, new Date(Date.now())),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:AUTHOR"),
|
||||
|
|
|
@ -55,7 +55,7 @@ class Serverinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.calendar + interaction.translate("common:CREATION"),
|
||||
value: client.functions.printDate(guild.createdAt),
|
||||
value: client.functions.printDate(client, guild.createdAt),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ class Stats extends BaseCommand {
|
|||
{
|
||||
name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"),
|
||||
value: interaction.translate("general/stats:ONLINE_CONTENT", {
|
||||
time: client.functions.convertTime(Date.now() + client.uptime, true, true, data.guildData.language),
|
||||
time: client.functions.convertTime(client, Date.now() + client.uptime, true, true, data.guildData.language),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ class Suggest extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
name: interaction.translate("common:DATE"),
|
||||
value: client.functions.printDate(new Date(Date.now())),
|
||||
value: client.functions.printDate(client, 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.functions.printDate(member.user.createdAt),
|
||||
value: client.functions.printDate(client, member.user.createdAt),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"),
|
||||
value: client.functions.printDate(member.joinedAt),
|
||||
value: client.functions.printDate(client, member.joinedAt),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -45,8 +45,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.functions.printDate(date, null, req.locale);
|
||||
req.convertTime = (time) => req.client.functions.convertTime(time, "to", true, req.locale);
|
||||
req.printDate = (date) => req.client.functions.printDate(client, date, null, req.locale);
|
||||
req.convertTime = (time) => req.client.functions.convertTime(client, time, "to", true, req.locale);
|
||||
}
|
||||
next();
|
||||
})
|
||||
|
|
|
@ -88,13 +88,14 @@ module.exports = {
|
|||
|
||||
/**
|
||||
* Beautify date
|
||||
* @param {import("../base/JaBa")} client Discord client
|
||||
* @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);
|
||||
printDate(client, date, format = "", locale = client.defaultLanguage) {
|
||||
const languageData = client.languages.find(language => language.name === locale);
|
||||
if (format === "" || format === null) format = languageData.defaultMomentFormat;
|
||||
|
||||
return moment(new Date(date))
|
||||
|
@ -104,14 +105,15 @@ module.exports = {
|
|||
|
||||
/**
|
||||
* Convert given time
|
||||
* @param {import("../base/JaBa")} client Discord client
|
||||
* @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);
|
||||
convertTime(client, time, type = false, noPrefix = false, locale = this.defaultLanguage) {
|
||||
const languageData = client.languages.find(language => language.name === locale);
|
||||
const m = moment(time).locale(languageData.moment);
|
||||
|
||||
return (type ? m.toNow(noPrefix) : m.fromNow(noPrefix));
|
||||
|
|
Loading…
Reference in a new issue