From 1aa62d135ec79e853a188f69fd3a030afc0cdaa3 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Thu, 3 Feb 2022 12:11:51 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B,=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B0=20=D0=BB=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20TTT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Economy/tictactoe.js | 9 +- helpers/tictactoe.js | 230 ++++++++++++---------- languages/ru-RU/economy/tictactoe.json | 21 +- languages/ru-RU/economy/transactions.json | 1 + languages/uk-UA/economy/tictactoe.json | 20 +- languages/uk-UA/economy/transactions.json | 1 + 6 files changed, 174 insertions(+), 108 deletions(-) diff --git a/commands/Economy/tictactoe.js b/commands/Economy/tictactoe.js index aa0e201e..237338d2 100644 --- a/commands/Economy/tictactoe.js +++ b/commands/Economy/tictactoe.js @@ -19,20 +19,17 @@ class TicTacToe extends Command { async run(message, args, data) { tictactoe(message, { + resultBtn: true, embedColor: data.config.embed.color, embedFoot: data.config.embed.footer }).then(async (winner) => { - message.sendT("economy/number:WON", { - winner: winner.username - }); - const memberData = await this.client.findOrCreateMember({ id: winner.id, guildID: message.guild.id }); const info = { - user: message.translate("economy/tictactoe:DESCRIPTION"), + user: message.translate("economy/transactions:TTT"), amount: 100, date: Date.now(), type: "got" @@ -40,7 +37,7 @@ class TicTacToe extends Command { memberData.transactions.push(info); - memberData.money = memberData.money + 100; + memberData.money += 100; memberData.save(); }); } diff --git a/helpers/tictactoe.js b/helpers/tictactoe.js index 2441d416..baf08221 100644 --- a/helpers/tictactoe.js +++ b/helpers/tictactoe.js @@ -35,61 +35,63 @@ async function tictactoe(message, options = []) { opponent = message.options.getUser(options.userSlash || "user"); if (!opponent) - return message.followUp({ - content: "Укажите пользователя!", + return message.reply({ + content: message.translate("economy/tictactoe:NO_USER"), ephemeral: true }); if (opponent.bot) - return message.followUp({ - content: "Вы не можете играть против ботов!", + return message.reply({ + content: message.translate("economy/tictactoe:BOT_USER"), ephemeral: true }); if (opponent.id == (message.user ? message.user : message.author).id) - return message.followUp({ - content: "Вы не можете играть с самим собой!", + return message.reply({ + content: message.translate("economy/tictactoe:YOURSELF"), ephemeral: true }); } else if (!message.commandId) { opponent = message.mentions.members.first()?.user; if (!opponent) - return message.channel.send({ - content: "Укажите пользователя!" + return message.reply({ + content: message.translate("economy/tictactoe:NO_USER") }); if (opponent.bot) - return message.followUp({ - content: "Вы не можете играть против ботов!", + return message.reply({ + content: message.translate("economy/tictactoe:BOT_USER"), ephemeral: true }); if (opponent.id === message.member.id) - return message.channel.send({ - content: - "Вы не можете играть с самим собой!" + return message.reply({ + content: message.translate("economy/tictactoe:YOURSELF") }); } - const foot = { text: options.embedFoot } || { text: "Удачи =)" }; + const foot = options.embedFoot ? { text: options.embedFoot } : { text: "Удачи =)" }; const acceptEmbed = new Discord.MessageEmbed() - .setTitle(`Ожидаю ответа ${opponent.tag}!`) + .setTitle(message.translate("economy/tictactoe:REQUEST_WAIT", { + user: opponent.tag + })) .setAuthor({ name: (message.user ? message.user : message.author).tag, iconURL: (message.user ? message.user : message.author).displayAvatarURL() }) .setColor(options.embedColor || "#075FFF") - .setFooter(foot); + .setFooter(foot) + .setTimestamp(); const accept = new Discord.MessageButton() - .setLabel("Принять") + .setLabel(message.translate("economy/tictactoe:ACCEPT")) .setStyle("SUCCESS") .setCustomId("acceptttt"); const decline = new Discord.MessageButton() - .setLabel("Отказаться") + .setLabel(message.translate("economy/tictactoe:DECLINE")) .setStyle("DANGER") .setCustomId("declinettt"); @@ -101,14 +103,18 @@ async function tictactoe(message, options = []) { let m; if (message.commandId) { - m = await message.followUp({ - content: "Хей, <@" + opponent.id + ">, вам предложили сыграть в крестики-нолики", + m = await message.reply({ + content: message.translate("economy/tictactoe:INVITE_USER", { + opponent: opponent.id + }), embeds: [acceptEmbed], components: [accep] }); } else if (!message.commandId) { m = await message.reply({ - content: "Хей, <@" + opponent.id + ">, вам предложили сыграть в крестики-нолики", + content: message.translate("economy/tictactoe:INVITE_USER", { + opponent: opponent.id + }), embeds: [acceptEmbed], components: [accep] }); @@ -120,7 +126,9 @@ async function tictactoe(message, options = []) { collector.on("collect", async (button) => { if (button.user.id !== opponent.id) return button.reply({ - content: `Запрос отправлен <@${opponent.id}>.`, + content: message.translate("economy/tictactoe:REQUEST_SEND", { + opponent: opponent.id + }), ephemeral: true }); @@ -129,9 +137,7 @@ async function tictactoe(message, options = []) { return collector.stop("decline"); } else if (button.customId == "acceptttt") { collector.stop(); - if (message.commandId) { - button.message.delete(); - } + if (message.commandId) button.message.delete(); const fighters = [ (message.user ? message.user : message.author).id, @@ -194,19 +200,20 @@ async function tictactoe(message, options = []) { const { MessageActionRow, MessageButton } = require("discord.js"); const epm = new Discord.MessageEmbed() - .setTitle("Крестики-нолики") + .setTitle(message.translate("economy/tictactoe:DESCRIPTION")) .setColor(options.embedColor || "#075FFF") .setFooter(foot) .setTimestamp(); let msg; if (message.commandId) { - msg = await message.followUp({ + msg = await message.reply({ embeds: [ epm.setDescription( - `Ожидаю ход | <@!${Args.userid}>, Ваш эмодзи: ${ - client.emojis.cache.get(o_emoji) || "⭕" - }` + message.translate("economy/tictactoe:WAITING", { + user: Args.userid, + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }) ) ] }); @@ -214,9 +221,10 @@ async function tictactoe(message, options = []) { msg = await button.message.edit({ embeds: [ epm.setDescription( - `Ожидаю ход | <@!${Args.userid}>, Ваш эмодзи: ${ - client.emojis.cache.get(o_emoji) || "⭕" - }` + message.translate("economy/tictactoe:WAITING", { + user: Args.userid, + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }) ) ] }); @@ -340,16 +348,18 @@ async function tictactoe(message, options = []) { if (options.resultBtn === true) return m .edit({ - content: `<@${fighters[1]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), components: buttons, embeds: [ epm.setDescription( - `<@!${fighters[1]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл.` + message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }) ) ] }) @@ -359,15 +369,17 @@ async function tictactoe(message, options = []) { else if (!options.resultBtn || options.resultBtn === false) return m .edit({ - content: `<@${fighters[1]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), embeds: [ epm.setDescription( - `<@!${fighters[1]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл\n\`\`\`\n${Args.a1.emoji + `${message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + })}\n\`\`\`\n${Args.a1.emoji .replace(o_emoji, "⭕") .replace(x_emoji, "❌")} | ${Args.a2.emoji .replace(o_emoji, "⭕") @@ -405,15 +417,17 @@ async function tictactoe(message, options = []) { if (options.resultBtn === true) return m .edit({ - content: `<@${fighters[0]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), components: buttons, embeds: [ epm.setDescription( - `<@!${fighters[0]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл` + message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }) ) ] }) @@ -423,15 +437,17 @@ async function tictactoe(message, options = []) { else if (!options.resultBtn || options.resultBtn === false) return m .edit({ - content: `<@${fighters[0]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), embeds: [ epm.setDescription( - `<@!${fighters[0]}> (${ - client.emojis.cache.get(o_emoji) || "⭕" - }) выиграл\n\`\`\`\n${Args.a1.emoji + `${message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + })}\n\`\`\`\n${Args.a1.emoji .replace(o_emoji, "⭕") .replace(x_emoji, "❌")} | ${Args.a2.emoji .replace(o_emoji, "⭕") @@ -520,15 +536,17 @@ async function tictactoe(message, options = []) { if (options.resultBtn === true) return m .edit({ - content: `<@${fighters[1]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), components: buttons, embeds: [ epm.setDescription( - `<@!${fighters[1]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл` + message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }) ) ] }) @@ -538,14 +556,16 @@ async function tictactoe(message, options = []) { else if (!options.resultBtn || options.resultBtn === false) return m .edit({ - content: `<@${fighters[1]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), embeds: [ epm.setDescription( - `<@!${fighters[1]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл\n\`\`\`\n${Args.a1.emoji + `${message.translate("economy/tictactoe:WON", { + winner: fighters[1], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + })}\n\`\`\`\n${Args.a1.emoji .replace(o_emoji, "⭕") .replace(x_emoji, "❌")} | ${Args.a2.emoji .replace(o_emoji, "⭕") @@ -583,15 +603,17 @@ async function tictactoe(message, options = []) { if (options.resultBtn === true) return m .edit({ - content: `<@${fighters[0]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), components: buttons, embeds: [ epm.setDescription( - `<@!${fighters[0]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл` + message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }) ) ] }) @@ -601,14 +623,16 @@ async function tictactoe(message, options = []) { else return m .edit({ - content: `<@${fighters[0]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл`, + content: message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + }), embeds: [ epm.setDescription( - `<@!${fighters[0]}> (${ - client.emojis.cache.get(x_emoji) || "❌" - }) выиграл\n\`\`\`\n${Args.a1.emoji + `${message.translate("economy/tictactoe:WON", { + winner: fighters[0], + emoji: client.emojis.cache.get(o_emoji) || "⭕" + })}\n\`\`\`\n${Args.a1.emoji .replace(o_emoji, "⭕") .replace(x_emoji, "❌")} | ${Args.a2.emoji .replace(o_emoji, "⭕") @@ -644,11 +668,10 @@ async function tictactoe(message, options = []) { content: `<@${Args.userid}>`, embeds: [ epm.setDescription( - `Ожидаю ход | <@!${Args.userid}> | Ваш эмодзи: ${ - Args.user == 0 - ? `${client.emojis.cache.get(o_emoji) || "⭕"}` - : `${client.emojis.cache.get(x_emoji) || "❌"}` - }` + message.translate("economy/tictactoe:WAITING", { + user: Args.userid, + emoji: Args.user == 0 ? `${client.emojis.cache.get(o_emoji) || "⭕"}` : `${client.emojis.cache.get(x_emoji) || "❌"}` + }) ) ], components: [a, b, c] @@ -663,7 +686,7 @@ async function tictactoe(message, options = []) { collector.on("collect", (b) => { if (b.user.id !== Args.userid) { b.reply({ - content: "Вы не можете играть сейчас!", + content: message.translate("economy/tictactoe:CANT_PLAY"), ephemeral: true }); @@ -690,8 +713,7 @@ async function tictactoe(message, options = []) { (prev, [key, value]) => ({ ...prev, [key]: fun(key, value) - }), - {} + }), {} ); const objectFilter = (obj, predicate) => Object.keys(obj) @@ -760,8 +782,8 @@ async function tictactoe(message, options = []) { if (options.resultBtn === true) return m .edit({ - content: "Ничья", - embeds: [epm.setDescription("Это ничья!")] + content: message.translate("economy/tictactoe:TIE"), + embeds: [epm.setDescription(message.translate("economy/tictactoe:TIE_DESC"))] }) .then((m) => { m.react(dashmoji); @@ -769,10 +791,10 @@ async function tictactoe(message, options = []) { else return m .edit({ - content: "Ничья", + content: message.translate("economy/tictactoe:TIE"), embeds: [ epm.setDescription( - `Это ничья!\n\`\`\`\n${Args.a1.emoji + `${message.translate("economy/tictactoe:TIE_DESC")}!\n\`\`\`\n${Args.a1.emoji .replace(o_emoji, "⭕") .replace(x_emoji, "❌")} | ${Args.a2.emoji .replace(o_emoji, "⭕") @@ -811,7 +833,9 @@ async function tictactoe(message, options = []) { collector.on("end", (collected, reason) => { if (collected.size === 0 && reason == "time") m.edit({ - content: `<@!${Args.userid}> не ответил вовремя! (30с)`, + content: message.translate("economy/tictactoe:NO_ANSWER", { + user: Args.userid + }), components: [] }); }); @@ -822,30 +846,36 @@ async function tictactoe(message, options = []) { collector.on("end", (collected, reason) => { if (reason == "time") { const embed = new Discord.MessageEmbed() - .setTitle("Запрос не принят вовремя") + .setTitle(message.translate("economy/tictactoe:NO_ANSWER_TITLE")) .setAuthor({ name: (message.user ? message.user : message.author).tag, iconURL: (message.user ? message.user : message.author).displayAvatarURL() }) .setColor(options.timeoutEmbedColor || "#C90000") .setFooter(foot) - .setDescription("Время вышло!\nЛимит: 30с"); + .setTimestamp() + .setDescription(message.translate("economy/tictactoe:TIMES_UP")); m.edit({ - content: "<@" + opponent.id + "> не принял запрос", + content: message.translate("economy/tictactoe:NOT_ANSWERED", { + user: opponent.id + }), embeds: [embed], components: [] }); } if (reason == "decline") { const embed = new Discord.MessageEmbed() - .setTitle("Игра отменена!") + .setTitle(message.translate("economy/tictactoe:CANCELED")) .setAuthor({ name: (message.user ? message.user : message.author).tag, iconURL: (message.user ? message.user : message.author).displayAvatarURL() }) .setColor(options.timeoutEmbedColor || "#C90000") .setFooter(foot) - .setDescription(`${opponent.user.tag} отказался от игры!`); + .setTimestamp() + .setDescription(message.translate("economy/tictactoe:NO_ANSWER", { + user: opponent.user.tag + })); m.edit({ embeds: [embed], components: [] @@ -853,7 +883,7 @@ async function tictactoe(message, options = []) { } }); } catch (err) { - console.log(`tictactoe | Ошибка: ${err.stack}`); + console.log(`tictactoe | ERROR: ${err.stack}`); } }); } diff --git a/languages/ru-RU/economy/tictactoe.json b/languages/ru-RU/economy/tictactoe.json index 303d1877..624d713a 100644 --- a/languages/ru-RU/economy/tictactoe.json +++ b/languages/ru-RU/economy/tictactoe.json @@ -1,5 +1,24 @@ { "DESCRIPTION": "Крестики-нолики!", "USAGE": "{{prefix}}tictactoe", - "EXAMPLES": "{{prefix}}tictactoe" + "EXAMPLES": "{{prefix}}tictactoe", + "NO_USER": "Укажите пользователя!", + "BOT_USER": "Вы не можете играть против бота!", + "YOURSELF": "Вы не можете играть с самим собой!", + "ACCEPT": "Принять", + "DECLINE": "Отказаться", + "INVITE_USER": "Хей, <@!{{opponent}}>, вам предложили сыграть в крестики-нолики", + "REQUEST_SEND": "Запрос отправлен <@!{{opponent}}>", + "REQUEST_WAIT": "Ожидаю ответа {{user}}", + "WAITING": "Ожидаю ход | <@!{{user}}>, Ваш эмодзи: {{emoji}}", + "WON": "<@!{{winner}}> ({{emoji}}) выиграл!", + "CANT_PLAY": "Сейчас не ваш ход!", + "TIE": "Ничья", + "TIE_DESC": "Никто не выиграл, это ничья!", + "NO_ANSWER": "<@!{{user}}> не ответил вовремя! (30с)", + "NO_ANSWER_TITLE": "Запрос не принят вовремя", + "NOT_ANSWERED": "<@{{user}}> не принял запрос!", + "CANCELED": "Игра отменена!", + "CANCELED_DESC": "{{user}} отказался от игры!", + "TIMES_UP": "Время вышло! Лимит: 30 секунд" } \ No newline at end of file diff --git a/languages/ru-RU/economy/transactions.json b/languages/ru-RU/economy/transactions.json index 8686e852..99bc3073 100644 --- a/languages/ru-RU/economy/transactions.json +++ b/languages/ru-RU/economy/transactions.json @@ -8,6 +8,7 @@ "WORDS": "Угадай слово", "NUMBERS": "Угадай число", "HORSERACE": "Конные скачки", + "TTT": "Крестики-нолики", "T_GOT": "Пополнение", "T_SEND": "Списание", "T_USER_GOT": "Источник", diff --git a/languages/uk-UA/economy/tictactoe.json b/languages/uk-UA/economy/tictactoe.json index 303d1877..a4ecdba4 100644 --- a/languages/uk-UA/economy/tictactoe.json +++ b/languages/uk-UA/economy/tictactoe.json @@ -1,5 +1,23 @@ { "DESCRIPTION": "Крестики-нолики!", "USAGE": "{{prefix}}tictactoe", - "EXAMPLES": "{{prefix}}tictactoe" + "EXAMPLES": "{{prefix}}tictactoe", + "NO_USER": "Укажите пользователя!", + "BOT_USER": "Вы не можете играть против бота!", + "YOURSELF": "Вы не можете играть с самим собой", + "ACCEPT": "Принять", + "DECLINE": "Отказаться", + "INVITE_USER": "Хей, <@!{{opponent}}>, вам предложили сыграть в крестики-нолики", + "REQUEST_SEND": "Запрос отправлен <@!{{opponent}}>.", + "WAITING": "Ожидаю ход | <@!{{user}}>, Ваш эмодзи: {{emoji}}", + "WON": "выиграл", + "CANT_PLAY": "Вы не можете играть сейчас!", + "TIE": "Ничья", + "TIE_DESC": "Никто не выиграл, это ничья!", + "NO_ANSWER": "<@!{{user}}> не ответил вовремя! (30с)", + "NO_ANSWER_TITLE": "Запрос не принят вовремя", + "NOT_ANSWERED": "<@{{user}}> не принял запрос!", + "CANCELED": "Игра отменена!", + "CANCELED_DESC": "{{user}} отказался от игры!", + "TIMES_UP": "Время вышло! Лимит: 30 секунд" } \ No newline at end of file diff --git a/languages/uk-UA/economy/transactions.json b/languages/uk-UA/economy/transactions.json index 8686e852..99bc3073 100644 --- a/languages/uk-UA/economy/transactions.json +++ b/languages/uk-UA/economy/transactions.json @@ -8,6 +8,7 @@ "WORDS": "Угадай слово", "NUMBERS": "Угадай число", "HORSERACE": "Конные скачки", + "TTT": "Крестики-нолики", "T_GOT": "Пополнение", "T_SEND": "Списание", "T_USER_GOT": "Источник",