2021-12-10 21:39:54 +05:00
|
|
|
const Command = require("../../base/Command.js"),
|
|
|
|
Discord = require("discord.js");
|
|
|
|
|
|
|
|
const asyncForEach = async (array, callback) => {
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
await callback(array[index], index, array);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class Credits extends Command {
|
2021-12-26 19:29:37 +05:00
|
|
|
constructor(client) {
|
2021-12-10 21:39:54 +05:00
|
|
|
super(client, {
|
|
|
|
name: "money",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
2022-01-01 00:50:09 +05:00
|
|
|
aliases: ["credits", "balance", "mon"],
|
2021-12-10 21:39:54 +05:00
|
|
|
memberPermissions: [],
|
2021-12-26 19:29:37 +05:00
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
2021-12-10 21:39:54 +05:00
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
|
|
|
cooldown: 1000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
async run(message, args, data) {
|
2021-12-10 21:39:54 +05:00
|
|
|
let member = await this.client.resolveMember(args[0], message.guild);
|
|
|
|
if (!member) member = message.member;
|
|
|
|
const user = member.user;
|
|
|
|
|
|
|
|
if (user.bot) return message.error("misc:BOT_USER");
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
const memberData = (message.author === user) ? data.memberData : await this.client.findOrCreateMember({
|
|
|
|
id: user.id,
|
|
|
|
guildID: message.guild.id
|
|
|
|
});
|
2021-12-10 21:39:54 +05:00
|
|
|
|
|
|
|
const commonsGuilds = this.client.guilds.cache.filter((g) => g.members.cache.get(user.id));
|
|
|
|
let globalMoney = 0;
|
|
|
|
await asyncForEach(commonsGuilds.array(), async (guild) => {
|
2021-12-26 19:29:37 +05:00
|
|
|
const memberData = await this.client.findOrCreateMember({
|
|
|
|
id: user.id,
|
|
|
|
guildID: guild.id
|
|
|
|
});
|
|
|
|
globalMoney += memberData.money;
|
|
|
|
globalMoney += memberData.bankSold;
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
const embed = new Discord.MessageEmbed()
|
|
|
|
.setAuthor(message.translate("economy/money:TITLE", {
|
|
|
|
username: member.user.username
|
2021-12-26 19:29:37 +05:00
|
|
|
}), member.user.displayAvatarURL({
|
|
|
|
size: 512,
|
|
|
|
dynamic: true,
|
|
|
|
format: "png"
|
|
|
|
}))
|
2021-12-30 20:12:46 +05:00
|
|
|
.addField(message.translate("economy/profile:CASH"), `**${memberData.money}** ${this.client.getNoun(memberData.money, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, true)
|
|
|
|
.addField(message.translate("economy/profile:BANK"), `**${memberData.bankSold}** ${this.client.getNoun(memberData.bankSold, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, true)
|
|
|
|
.addField(message.translate("economy/profile:GLOBAL"), `**${globalMoney}** ${this.client.getNoun(globalMoney, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, true)
|
2021-12-10 21:39:54 +05:00
|
|
|
.setColor(this.client.config.embed.color)
|
|
|
|
.setFooter(this.client.config.embed.footer);
|
|
|
|
message.channel.send(embed);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Credits;
|