diff --git a/commands/Economy/birthdate.js b/commands/Economy/birthdate.js index 3c9df19e..c50cbee9 100644 --- a/commands/Economy/birthdate.js +++ b/commands/Economy/birthdate.js @@ -24,7 +24,6 @@ class Birthdate extends Command { const [day, month, year] = tArgs; if (!day || !month || !year) return message.error("economy/birthdate:INVALID_DATE"); - // Gets the string of the date const match = date.match(/\d+/g); if (!match) return message.error("economy/birthdate:INVALID_DATE"); diff --git a/commands/Economy/marry.js b/commands/Economy/marry.js index d913f198..34e85e7d 100644 --- a/commands/Economy/marry.js +++ b/commands/Economy/marry.js @@ -20,12 +20,8 @@ class Marry extends Command { } async run(message, args, data) { - // if the message author is already wedded - if (data.userData.lover) return message.error("economy/marry:ALREADY_MARRIED", { - prefix: data.guild.prefix - }); + if (data.userData.lover) return message.error("economy/marry:ALREADY_MARRIED", { prefix: data.guild.prefix }); - // Gets the first mentionned member const member = await this.client.resolveMember(args[0], message.guild); if (!member) return message.error("economy/marry:INVALID_MEMBER"); @@ -33,13 +29,8 @@ class Marry extends Command { id: member.id }); - // if the member is already wedded - if (userData.lover) return message.error("economy/marry:ALREADY_MARRIED_USER", { - username: member.user.tag - }); - + if (userData.lover) return message.error("economy/marry:ALREADY_MARRIED_USER", { username: member.user.tag }); if (member.user.bot) return message.error("economy/marry:BOT_USER"); - if (member.id === message.author.id) return message.error("economy/marry:YOURSELF"); for (const requester in pendings) { diff --git a/commands/Economy/money.js b/commands/Economy/money.js index 50a5c00e..61615e6d 100644 --- a/commands/Economy/money.js +++ b/commands/Economy/money.js @@ -1,20 +1,22 @@ const Command = require("../../base/Command.js"), Discord = require("discord.js"); -// const asyncForEach = async (array, callback) => { -// for (let index = 0; index < array.size; index++) { -// await callback(index, array); -// }; -// }; +const asyncForEach = async (collection, callback) => { + const allPromises = collection.map(async key => { + await callback(key); + }); -class Credits extends Command { + return await Promise.all(allPromises); +}; + +class Money extends Command { constructor(client) { super(client, { name: "money", dirname: __dirname, enabled: true, guildOnly: true, - aliases: ["credits", "balance", "mon"], + aliases: ["balance", "mon"], memberPermissions: [], botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], nsfw: false, @@ -36,16 +38,15 @@ class Credits extends Command { }); const commonsGuilds = this.client.guilds.cache.filter((g) => g.members.cache.get(user.id)); - const globalMoney = memberData.money + memberData.bankSold; - // let globalMoney = 0; - // await asyncForEach(commonsGuilds, async (guild) => { - // const memberData = await this.client.findOrCreateMember({ - // id: user.id, - // guildID: guild.id - // }); - // globalMoney += memberData.money; - // globalMoney += memberData.bankSold; - // }); + let globalMoney = 0; + await asyncForEach(commonsGuilds, async (guild) => { + const data = await this.client.findOrCreateMember({ + id: user.id, + guildID: guild.id + }); + globalMoney += data.money; + globalMoney += data.bankSold; + }); const embed = new Discord.MessageEmbed() .setAuthor({ @@ -71,4 +72,4 @@ class Credits extends Command { } }; -module.exports = Credits; \ No newline at end of file +module.exports = Money; \ No newline at end of file diff --git a/commands/Economy/profile.js b/commands/Economy/profile.js index a3bcb358..79100297 100644 --- a/commands/Economy/profile.js +++ b/commands/Economy/profile.js @@ -1,11 +1,13 @@ const Command = require("../../base/Command.js"), Discord = require("discord.js"); -// const asyncForEach = async (array, callback) => { -// for (let index = 0; index < array.size; index++) { -// await callback(index, array); -// }; -// }; +const asyncForEach = async (collection, callback) => { + const allPromises = collection.map(async key => { + await callback(key); + }); + + return await Promise.all(allPromises); +}; class Profile extends Command { constructor(client) { @@ -24,33 +26,30 @@ class Profile extends Command { } async run(message, args, data) { - const client = this.client; - const arg = args[0] || message.author - let member = await client.resolveMember(arg, message.guild); + let member = await this.client.resolveMember(arg, message.guild); if (!member) member = message.member; if (member.user.bot) return message.error("economy/profile:BOT_USER"); - const memberData = (member.id === message.author.id ? data.memberData : await client.findOrCreateMember({ + const memberData = (member.id === message.author.id ? data.memberData : await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id })); - const userData = (member.id === message.author.id ? data.userData : await client.findOrCreateUser({ + const userData = (member.id === message.author.id ? data.userData : await this.client.findOrCreateUser({ id: member.id })); if (userData.lover && !this.client.users.cache.get(userData.lover)) await this.client.users.fetch(userData.lover, true); - const commonsGuilds = client.guilds.cache.filter((g) => g.members.cache.get(member.id)); - const globalMoney = memberData.money + memberData.bankSold; - // let globalMoney = 0; - // await asyncForEach(commonsGuilds, async (guild) => { - // const memberData = await client.findOrCreateMember({ - // id: member.id, - // guildID: guild.id - // }); - // globalMoney += memberData.money; - // globalMoney += memberData.bankSold; - // }); + const commonsGuilds = this.client.guilds.cache.filter((g) => g.members.cache.get(member.id)); + let globalMoney = 0; + await asyncForEach(commonsGuilds, async (guild) => { + const data = await this.client.findOrCreateMember({ + id: member.id, + guildID: guild.id + }); + globalMoney += data.money; + globalMoney += data.bankSold; + }); const profileEmbed = new Discord.MessageEmbed() .setAuthor({ diff --git a/commands/Music/np.js b/commands/Music/np.js index e223952c..5ed3dc5b 100644 --- a/commands/Music/np.js +++ b/commands/Music/np.js @@ -24,20 +24,15 @@ class Np extends Command { if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!queue) return message.error("music/play:NOT_PLAYING"); - // Gets the current song const track = queue.songs[0]; const status = queue => - `Фильтры: \`${queue.filters.join(", ") - || "Выкл"}\` | Повтор: \`${ + `Фильтры: \`${queue.filters.join(", ") || "Выкл"}\` | Повтор: \`${ queue.repeatMode - ? queue.repeatMode === 2 - ? "Очереди" - : "Трека" + ? queue.repeatMode === 2 ? "Очереди" : "Трека" : "Выкл" }\` | Автовоспроизведение: \`${queue.autoplay ? "Вкл" : "Выкл"}\``; - // Generate discord embed to display song informations const embed = new Discord.MessageEmbed() .setAuthor({ name: message.translate("music/queue:TITLE") @@ -53,7 +48,6 @@ class Np extends Command { }) .setTimestamp(); - // Send the embed in the current channel message.channel.send({ embeds: [embed] }); diff --git a/languages/ru-RU/economy/profile.json b/languages/ru-RU/economy/profile.json index 5608bfcb..5a52d365 100644 --- a/languages/ru-RU/economy/profile.json +++ b/languages/ru-RU/economy/profile.json @@ -9,7 +9,7 @@ "NO_BIO": "Биография отсутствует", "CASH": "💵 Кредиты", "BANK": "💳 Банк", - "GLOBAL": "🌍 Всего кредитов на текущем сервере", + "GLOBAL": "🌍 Всего кредитов на всех серверах", "REPUTATION": "🎩 Репутация", "LEVEL": "📊 Уровень", "EXP": "🔮 Опыт",