mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
Наконец то фикс
Возвращены кредиты со всех серверов в profile и money
This commit is contained in:
parent
c596f314e1
commit
e6be809cec
6 changed files with 44 additions and 60 deletions
|
@ -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");
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
module.exports = Money;
|
|
@ -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({
|
||||
|
|
|
@ -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]
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"NO_BIO": "Биография отсутствует",
|
||||
"CASH": "💵 Кредиты",
|
||||
"BANK": "💳 Банк",
|
||||
"GLOBAL": "🌍 Всего кредитов на текущем сервере",
|
||||
"GLOBAL": "🌍 Всего кредитов на всех серверах",
|
||||
"REPUTATION": "🎩 Репутация",
|
||||
"LEVEL": "📊 Уровень",
|
||||
"EXP": "🔮 Опыт",
|
||||
|
|
Loading…
Reference in a new issue