mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
fix all languages errors 😎
This commit is contained in:
parent
a8d8517876
commit
59b191aadc
16 changed files with 30 additions and 27 deletions
|
@ -94,7 +94,7 @@ class Birthdate extends BaseCommand {
|
|||
await data.userData.save();
|
||||
|
||||
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()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,12 +114,12 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ class Rep extends BaseCommand {
|
|||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now())
|
||||
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()),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class Transactions extends BaseCommand {
|
|||
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`,
|
||||
)}: ${client.functions.printDate(client, t.date, "Do MMMM YYYY, HH:mm", interaction.getLocale())}\n`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Work extends BaseCommand {
|
|||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now())
|
||||
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;
|
||||
|
|
|
@ -60,7 +60,7 @@ class Number extends BaseCommand {
|
|||
const parsedNumber = parseInt(msg.content, 10);
|
||||
|
||||
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({
|
||||
content: interaction.translate("fun/number:GAME_STATS", {
|
||||
winner: msg.author.toString(),
|
||||
|
|
|
@ -116,13 +116,13 @@ class Boosters extends BaseCommand {
|
|||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
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 });
|
||||
|
||||
const embeds = generateBoostersEmbeds(client, interaction, boosters, data.guildData);
|
||||
const embeds = generateBoostersEmbeds(client, interaction, boosters);
|
||||
|
||||
const row = new ActionRowBuilder().addComponents(
|
||||
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("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Array} boosters
|
||||
* @param {import("../../base/Guild")} guildData
|
||||
* @returns
|
||||
*/
|
||||
function generateBoostersEmbeds(client, interaction, boosters, guildData) {
|
||||
function generateBoostersEmbeds(client, interaction, boosters) {
|
||||
const embeds = [];
|
||||
let k = 10;
|
||||
|
||||
|
@ -159,7 +158,7 @@ function generateBoostersEmbeds(client, interaction, boosters, guildData) {
|
|||
let j = i;
|
||||
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()
|
||||
.setTitle(interaction.translate("general/boosters:BOOSTERS_LIST"))
|
||||
|
|
|
@ -79,7 +79,7 @@ class Remindme extends BaseCommand {
|
|||
|
||||
interaction.success("general/remindme:SAVED", {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class Report extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
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"),
|
||||
|
|
|
@ -34,7 +34,7 @@ class Serverinfo extends BaseCommand {
|
|||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const guild = interaction.guild;
|
||||
|
||||
await guild.members.fetch();
|
||||
|
@ -58,7 +58,7 @@ class Serverinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ class Stats extends BaseCommand {
|
|||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
|
||||
const servers = client.guilds.cache.size - 1;
|
||||
let users = 0;
|
||||
|
@ -72,7 +72,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(client, Date.now() + client.uptime, true, false, data?.guildData?.language),
|
||||
time: client.functions.convertTime(client, Date.now() + client.uptime, true, false, interaction.getLocale()),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ class Suggest extends BaseCommand {
|
|||
.addFields([
|
||||
{
|
||||
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"),
|
||||
|
|
|
@ -43,7 +43,7 @@ class Userinfo extends BaseCommand {
|
|||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const member = interaction.options.getMember("user") || interaction.member;
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
|
@ -78,12 +78,12 @@ class Userinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ class CloseTicket extends BaseCommand {
|
|||
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
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 ----";
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ class CreateTicketEmbed extends BaseCommand {
|
|||
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
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 ----";
|
||||
|
||||
|
@ -186,7 +186,7 @@ class CreateTicketEmbed extends BaseCommand {
|
|||
|
||||
let transcript = "---- TICKET CREATED ----\n";
|
||||
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 ----";
|
||||
|
||||
|
|
|
@ -4,15 +4,19 @@ User.prototype.getUsername = function () {
|
|||
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) {
|
||||
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.";
|
||||
|
||||
return language(key, args);
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
if (options.edit) return await this.editReply({ content: string, ephemeral: options.ephemeral || false });
|
||||
|
|
Loading…
Reference in a new issue