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 Profile extends Command {
|
2021-12-26 19:29:37 +05:00
|
|
|
constructor(client) {
|
2021-12-10 21:39:54 +05:00
|
|
|
super(client, {
|
|
|
|
name: "profile",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
2021-12-31 21:10:21 +05:00
|
|
|
aliases: ["prof"],
|
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,
|
2022-01-01 00:50:09 +05:00
|
|
|
cooldown: 1000
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
async run(message, args, data) {
|
2021-12-10 21:39:54 +05:00
|
|
|
const client = this.client;
|
|
|
|
|
2021-12-12 20:40:14 +05:00
|
|
|
const arg = args[0] || message.author
|
|
|
|
let member = await client.resolveMember(arg, message.guild);
|
2021-12-10 21:39:54 +05:00
|
|
|
if (!member) member = message.member;
|
|
|
|
if (member.user.bot) return message.error("economy/profile:BOT_USER");
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
const memberData = (member.id === message.author.id ? data.memberData : await client.findOrCreateMember({
|
|
|
|
id: member.id,
|
|
|
|
guildID: message.guild.id
|
|
|
|
}));
|
|
|
|
const userData = (member.id === message.author.id ? data.userData : await client.findOrCreateUser({
|
|
|
|
id: member.id
|
|
|
|
}));
|
2021-12-10 21:39:54 +05:00
|
|
|
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));
|
|
|
|
let globalMoney = 0;
|
|
|
|
await asyncForEach(commonsGuilds.array(), async (guild) => {
|
2021-12-26 19:29:37 +05:00
|
|
|
const memberData = await client.findOrCreateMember({
|
|
|
|
id: member.id,
|
|
|
|
guildID: guild.id
|
|
|
|
});
|
2021-12-12 20:40:14 +05:00
|
|
|
globalMoney += memberData.money;
|
|
|
|
globalMoney += memberData.bankSold;
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
const profileEmbed = new Discord.MessageEmbed()
|
|
|
|
.setAuthor(message.translate("economy/profile:TITLE", {
|
|
|
|
username: member.user.tag
|
2021-12-26 19:29:37 +05:00
|
|
|
}), member.user.displayAvatarURL({
|
|
|
|
size: 512,
|
|
|
|
dynamic: true,
|
|
|
|
format: "png"
|
|
|
|
}))
|
|
|
|
.attachFiles([{
|
|
|
|
attachment: await userData.getAchievements(),
|
|
|
|
name: "achievements.png"
|
|
|
|
}])
|
2021-12-10 21:39:54 +05:00
|
|
|
.setImage("attachment://achievements.png")
|
2021-12-24 20:58:38 +05:00
|
|
|
.addField(message.translate("economy/profile:BIO"), userData.bio ? userData.bio : message.translate("economy/profile:NO_BIO"))
|
2022-01-03 01:45:20 +05:00
|
|
|
.addField(message.translate("economy/profile:CASH"), `**${memberData.money}** ${message.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}** ${message.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}** ${message.getNoun(globalMoney, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, true)
|
|
|
|
.addField(message.translate("economy/profile:REPUTATION"), `**${userData.rep}** ${message.getNoun(userData.rep, message.translate("misc:NOUNS:POINTS:1"), message.translate("misc:NOUNS:POINTS:2"), message.translate("misc:NOUNS:POINTS:5"))}`, true)
|
2021-12-10 21:39:54 +05:00
|
|
|
.addField(message.translate("economy/profile:LEVEL"), `**${memberData.level}**`, true)
|
2021-12-25 15:32:59 +05:00
|
|
|
.addField(message.translate("economy/profile:EXP"), `**${memberData.exp}/${5 * (memberData.level * memberData.level) + 80 * memberData.level + 100}** xp`, true)
|
2021-12-10 21:39:54 +05:00
|
|
|
.addField(message.translate("economy/profile:REGISTERED"), message.printDate(new Date(memberData.registeredAt)), true)
|
2021-12-26 19:29:37 +05:00
|
|
|
.addField(message.translate("economy/profile:BIRTHDATE"), (!userData.birthdate ? message.translate("economy/profile:NO_BIRTHDATE") : message.printDate(new Date(userData.birthdate))), true)
|
2021-12-10 21:39:54 +05:00
|
|
|
.addField(message.translate("economy/profile:LOVER"), (!userData.lover ? message.translate("economy/profile:NO_LOVER") : this.client.users.cache.get(userData.lover).tag), true)
|
|
|
|
.addField(message.translate("economy/profile:ACHIEVEMENTS"), message.translate("economy/profile:ACHIEVEMENTS_CONTENT", {
|
|
|
|
prefix: data.guild.prefix
|
|
|
|
}))
|
|
|
|
.setColor(data.config.embed.color) // Sets the color of the embed
|
|
|
|
.setFooter(data.config.embed.footer) // Sets the footer of the embed
|
|
|
|
.setTimestamp();
|
|
|
|
|
|
|
|
message.channel.send(profileEmbed); // Send the embed in the current channel
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Profile;
|