use guild's locale in printDate

This commit is contained in:
Jonny_Bro (Nikita) 2023-07-10 20:13:23 +05:00
parent cea32c0deb
commit 78cfdb92a8
9 changed files with 14 additions and 14 deletions

View file

@ -93,7 +93,7 @@ class Birthdate extends BaseCommand {
await data.userData.save(); await data.userData.save();
interaction.success("economy/birthdate:SUCCESS", { interaction.success("economy/birthdate:SUCCESS", {
date: client.functions.printDate(client, d), date: client.functions.printDate(client, d, null, data.guildData.language),
}); });
} }
} }

View file

@ -114,12 +114,12 @@ class Profile extends BaseCommand {
}, },
{ {
name: interaction.translate("economy/profile:REGISTERED"), name: interaction.translate("economy/profile:REGISTERED"),
value: client.functions.printDate(client, new Date(memberData.registeredAt)), value: client.functions.printDate(client, new Date(memberData.registeredAt), null, data.guildData.language),
inline: true, inline: true,
}, },
{ {
name: interaction.translate("economy/profile:BIRTHDATE"), name: interaction.translate("economy/profile:BIRTHDATE"),
value: !userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(client, new Date(userData.birthdate)), value: !userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(client, new Date(userData.birthdate), null, data.guildData.language),
inline: true, inline: true,
}, },
{ {

View file

@ -76,7 +76,7 @@ class Report extends BaseCommand {
.addFields([ .addFields([
{ {
name: interaction.translate("common:DATE"), name: interaction.translate("common:DATE"),
value: client.functions.printDate(client, new Date(Date.now())), value: client.functions.printDate(client, new Date(Date.now()), null, data.guildData.language),
}, },
{ {
name: interaction.translate("common:AUTHOR"), name: interaction.translate("common:AUTHOR"),

View file

@ -34,7 +34,7 @@ class Serverinfo extends BaseCommand {
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction, data) {
const guild = interaction.guild; const guild = interaction.guild;
await guild.members.fetch(); await guild.members.fetch();
@ -58,7 +58,7 @@ class Serverinfo extends BaseCommand {
}, },
{ {
name: client.customEmojis.calendar + interaction.translate("common:CREATION"), name: client.customEmojis.calendar + interaction.translate("common:CREATION"),
value: client.functions.printDate(client, guild.createdAt), value: client.functions.printDate(client, guild.createdAt, null, data.guildData.language),
inline: true, inline: true,
}, },
{ {

View file

@ -60,7 +60,7 @@ class Suggest extends BaseCommand {
.addFields([ .addFields([
{ {
name: interaction.translate("common:DATE"), name: interaction.translate("common:DATE"),
value: client.functions.printDate(client, new Date(Date.now())), value: client.functions.printDate(client, new Date(Date.now()), null, data.guildData.language),
}, },
{ {
name: interaction.translate("common:AUTHOR"), name: interaction.translate("common:AUTHOR"),

View file

@ -43,7 +43,7 @@ class Userinfo extends BaseCommand {
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction, data) {
const member = interaction.options.getMember("user") || interaction.member; const member = interaction.options.getMember("user") || interaction.member;
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setAuthor({ .setAuthor({
@ -78,12 +78,12 @@ class Userinfo extends BaseCommand {
}, },
{ {
name: client.customEmojis.calendar + " " + interaction.translate("common:CREATION"), name: client.customEmojis.calendar + " " + interaction.translate("common:CREATION"),
value: client.functions.printDate(client, member.user.createdAt), value: client.functions.printDate(client, member.user.createdAt, null, data.guildData.language),
inline: true, inline: true,
}, },
{ {
name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"), name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"),
value: client.functions.printDate(client, member.joinedAt), value: client.functions.printDate(client, member.joinedAt, null, data.guildData.language),
inline: true, inline: true,
}, },
{ {

View file

@ -83,7 +83,7 @@ class CloseTicket extends BaseCommand {
let transcript = "---- TICKET CREATED ----\n"; let transcript = "---- TICKET CREATED ----\n";
messages.forEach(message => { messages.forEach(message => {
transcript += `[${client.functions.printDate(client, message.createdTimestamp)}] ${message.author.getUsername()}: ${message.content}\n`; transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, data.guildData.language)}] ${message.author.getUsername()}: ${message.content}\n`;
}); });
transcript += "---- TICKET CLOSED ----"; transcript += "---- TICKET CLOSED ----";

View file

@ -140,7 +140,7 @@ class CreateTicketEmbed extends BaseCommand {
let transcript = "---- TICKET CREATED ----\n"; let transcript = "---- TICKET CREATED ----\n";
messages.forEach(message => { messages.forEach(message => {
transcript += `[${client.functions.printDate(client, message.createdTimestamp)}] ${message.author.getUsername()}: ${message.content}\n`; transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.guild.data.language)}] ${message.author.getUsername()}: ${message.content}\n`;
}); });
transcript += "---- TICKET CLOSED ----"; transcript += "---- TICKET CLOSED ----";
@ -180,7 +180,7 @@ class CreateTicketEmbed extends BaseCommand {
let transcript = "---- TICKET CREATED ----\n"; let transcript = "---- TICKET CREATED ----\n";
messages.forEach(message => { messages.forEach(message => {
transcript += `[${client.functions.printDate(client, message.createdTimestamp)}] ${message.author.getUsername()}: ${message.content}\n`; transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.guild.data.language)}] ${message.author.getUsername()}: ${message.content}\n`;
}); });
transcript += "---- TICKET CLOSED ----"; transcript += "---- TICKET CLOSED ----";

View file

@ -94,7 +94,7 @@ module.exports = {
* @param {String} locale Language * @param {String} locale Language
* @returns {String} Beautified date * @returns {String} Beautified date
*/ */
printDate(client, date, format = "", locale = client.defaultLanguage) { printDate(client, date, format = null, locale = client.defaultLanguage) {
const languageData = client.languages.find(language => language.name === locale); const languageData = client.languages.find(language => language.name === locale);
if (format === "" || format === null) format = languageData.defaultMomentFormat; if (format === "" || format === null) format = languageData.defaultMomentFormat;
return moment(new Date(date)).locale(languageData.moment).format(format); return moment(new Date(date)).locale(languageData.moment).format(format);