fix all languages errors 😎

This commit is contained in:
Jonny_Bro (Nikita) 2023-12-14 18:58:19 +05:00
parent a8d8517876
commit 59b191aadc
16 changed files with 30 additions and 27 deletions

View file

@ -94,7 +94,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, "Do MMMM YYYY", data.guildData.language), date: client.functions.printDate(client, d, "Do MMMM YYYY", interaction.getLocale()),
}); });
} }
} }

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), null, data.guildData.language), value: client.functions.printDate(client, new Date(memberData.registeredAt), null, interaction.getLocale()),
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), "Do MMMM YYYY", data.guildData.language), value: !userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(client, new Date(userData.birthdate), "Do MMMM YYYY", interaction.getLocale()),
inline: true, inline: true,
}, },
{ {

View file

@ -49,7 +49,7 @@ class Rep extends BaseCommand {
if (isInCooldown) { if (isInCooldown) {
if (isInCooldown > Date.now()) if (isInCooldown > Date.now())
return interaction.error("economy/rep:COOLDOWN", { return interaction.error("economy/rep:COOLDOWN", {
time: client.functions.convertTime(client, isInCooldown, true, false, data.guildData.language), time: client.functions.convertTime(client, isInCooldown, true, false, interaction.getLocale()),
}); });
} }

View file

@ -69,7 +69,7 @@ class Transactions extends BaseCommand {
array.push( 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( `${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", "economy/transactions:T_DATE",
)}: ${client.functions.printDate(client, t.date, "Do MMMM YYYY, HH:mm", data.guildData.language)}\n`, )}: ${client.functions.printDate(client, t.date, "Do MMMM YYYY, HH:mm", interaction.getLocale())}\n`,
); );
}); });

View file

@ -39,7 +39,7 @@ class Work extends BaseCommand {
if (isInCooldown) { if (isInCooldown) {
if (isInCooldown > Date.now()) if (isInCooldown > Date.now())
return interaction.error("economy/work:COOLDOWN", { return interaction.error("economy/work:COOLDOWN", {
time: client.functions.convertTime(client, isInCooldown, true, false, data.guildData.language), time: client.functions.convertTime(client, isInCooldown, true, false, interaction.getLocale()),
}); });
} }
if (Date.now() > data.memberData.cooldowns.work + 24 * 60 * 60 * 1000) data.memberData.workStreak = 0; if (Date.now() > data.memberData.cooldowns.work + 24 * 60 * 60 * 1000) data.memberData.workStreak = 0;

View file

@ -60,7 +60,7 @@ class Number extends BaseCommand {
const parsedNumber = parseInt(msg.content, 10); const parsedNumber = parseInt(msg.content, 10);
if (parsedNumber === number) { if (parsedNumber === number) {
const time = client.functions.convertTime(client, gameCreatedAt, false, true, data.guildData.language); const time = client.functions.convertTime(client, gameCreatedAt, false, true, interaction.getLocale());
interaction.channel.send({ interaction.channel.send({
content: interaction.translate("fun/number:GAME_STATS", { content: interaction.translate("fun/number:GAME_STATS", {
winner: msg.author.toString(), winner: msg.author.toString(),

View file

@ -116,13 +116,13 @@ class Boosters extends BaseCommand {
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince); const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true }); if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
const embeds = generateBoostersEmbeds(client, interaction, boosters, data.guildData); const embeds = generateBoostersEmbeds(client, interaction, boosters);
const row = new ActionRowBuilder().addComponents( const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("boosters_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"), new ButtonBuilder().setCustomId("boosters_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
@ -144,10 +144,9 @@ class Boosters extends BaseCommand {
* @param {import("../../base/Client")} client * @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} boosters * @param {Array} boosters
* @param {import("../../base/Guild")} guildData
* @returns * @returns
*/ */
function generateBoostersEmbeds(client, interaction, boosters, guildData) { function generateBoostersEmbeds(client, interaction, boosters) {
const embeds = []; const embeds = [];
let k = 10; let k = 10;
@ -159,7 +158,7 @@ function generateBoostersEmbeds(client, interaction, boosters, guildData) {
let j = i; let j = i;
k += 10; k += 10;
const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(client, member.premiumSince, null, guildData.language)}**`).join("\n"); const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(client, member.premiumSince, null, interaction.getLocale())}**`).join("\n");
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setTitle(interaction.translate("general/boosters:BOOSTERS_LIST")) .setTitle(interaction.translate("general/boosters:BOOSTERS_LIST"))

View file

@ -79,7 +79,7 @@ class Remindme extends BaseCommand {
interaction.success("general/remindme:SAVED", { interaction.success("general/remindme:SAVED", {
message, message,
time: moment(rData.sendAt).locale(data?.guildData?.language || "en-US").format("dddd, Do MMMM YYYY, HH:mm:ss"), time: moment(rData.sendAt).locale(interaction.getLocale()).format("dddd, Do MMMM YYYY, HH:mm:ss"),
}, { edit: true }); }, { edit: 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()), null, data.guildData.language), value: client.functions.printDate(client, new Date(Date.now()), null, interaction.getLocale()),
}, },
{ {
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, data) { async execute(client, interaction) {
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, null, data.guildData.language), value: client.functions.printDate(client, guild.createdAt, null, interaction.getLocale()),
inline: true, inline: true,
}, },
{ {

View file

@ -34,7 +34,7 @@ class Stats extends BaseCommand {
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction) {
const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount; const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
const servers = client.guilds.cache.size - 1; const servers = client.guilds.cache.size - 1;
let users = 0; let users = 0;
@ -72,7 +72,7 @@ class Stats extends BaseCommand {
{ {
name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"), name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"),
value: interaction.translate("general/stats:ONLINE_CONTENT", { value: interaction.translate("general/stats:ONLINE_CONTENT", {
time: client.functions.convertTime(client, Date.now() + client.uptime, true, false, data?.guildData?.language), time: client.functions.convertTime(client, Date.now() + client.uptime, true, false, interaction.getLocale()),
}), }),
}, },
{ {

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()), null, data.guildData.language), value: client.functions.printDate(client, new Date(Date.now()), null, interaction.getLocale()),
}, },
{ {
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, data) { async execute(client, interaction) {
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, null, data.guildData.language), value: client.functions.printDate(client, member.user.createdAt, null, interaction.getLocale()),
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, null, data.guildData.language), value: client.functions.printDate(client, member.joinedAt, null, interaction.getLocale()),
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, null, data.guildData.language)}] ${message.author.getUsername()}: ${message.content}\n`; transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
}); });
transcript += "---- TICKET CLOSED ----"; transcript += "---- TICKET CLOSED ----";

View file

@ -146,7 +146,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, null, interaction.guild.data.language)}] ${message.author.getUsername()}: ${message.content}\n`; transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
}); });
transcript += "---- TICKET CLOSED ----"; transcript += "---- TICKET CLOSED ----";
@ -186,7 +186,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, null, interaction.guild.data.language)}] ${message.author.getUsername()}: ${message.content}\n`; transcript += `[${client.functions.printDate(client, message.createdTimestamp, null, interaction.getLocale())}] ${message.author.getUsername()}: ${message.content}\n`;
}); });
transcript += "---- TICKET CLOSED ----"; transcript += "---- TICKET CLOSED ----";

View file

@ -4,15 +4,19 @@ User.prototype.getUsername = function () {
return this.discriminator === "0" ? this.username : this.tag; return this.discriminator === "0" ? this.username : this.tag;
}; };
BaseInteraction.prototype.getLocale = function () {
return this.guild ? this.guild.data.language : "en-US";
};
BaseInteraction.prototype.translate = function (key, args) { BaseInteraction.prototype.translate = function (key, args) {
const language = this.client.translations.get(this.guild ? this.guild.data.language : "en-US"); const language = this.client.translations.get(this.getLocale());
if (!language) throw "Interaction: Invalid language set in data."; if (!language) throw "Interaction: Invalid language set in data.";
return language(key, args); return language(key, args);
}; };
BaseInteraction.prototype.replyT = async function (key, args, options = {}) { BaseInteraction.prototype.replyT = async function (key, args, options = {}) {
const translated = this.translate(key, args, this.guild.data.language ?? "en-US"); const translated = this.translate(key, args, this.getLocale());
const string = options.prefixEmoji ? `${this.client.customEmojis[options.prefixEmoji]} | ${translated}` : translated; const string = options.prefixEmoji ? `${this.client.customEmojis[options.prefixEmoji]} | ${translated}` : translated;
if (options.edit) return await this.editReply({ content: string, ephemeral: options.ephemeral || false }); if (options.edit) return await this.editReply({ content: string, ephemeral: options.ephemeral || false });