JaBa/TO REWRITE/General/userinfo.js

94 lines
4.3 KiB
JavaScript
Raw Normal View History

const Command = require("../../base/Command"),
Discord = require("discord.js");
class Userinfo extends Command {
constructor(client) {
super(client, {
name: "userinfo",
dirname: __dirname,
enabled: true,
guildOnly: false,
aliases: ["ui"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 1000
});
}
async run(message, args, data) {
let displayPresence = true;
const isID = !isNaN(args[0]);
let user;
if (!args[0]) user = message.author;
if (message.mentions.users.first()) user = message.mentions.users.first();
if (isID && !user) {
user = this.client.users.cache.get(args[0]);
if (!user) {
user = await this.client.users.fetch(args[0], true).catch(() => {});
displayPresence = false;
}
}
if (!user) return message.error("general/userinfo:INVALID_USER");
let member = null;
if (message.guild) member = await message.guild.members.fetch(user).catch(() => {});
const embed = new Discord.MessageEmbed()
.setAuthor({
name: `${user.tag} (${user.id})`,
iconURL: user.displayAvatarURL({
size: 512,
dynamic: true,
format: "png"
})
})
.setThumbnail(user.displayAvatarURL({
dynamic: true
}))
.addField(":man: " + message.translate("common:USERNAME"), user.username, true)
.addField(this.client.customEmojis.discriminator + " " + message.translate("common:DISCRIMINATOR"), user.discriminator, true)
.addField(this.client.customEmojis.bot + " " + message.translate("common:ROBOT"), (user.bot ? message.translate("common:YES") : message.translate("common:NO")), true)
.addField(this.client.customEmojis.calendar + " " + message.translate("common:CREATION"), this.client.printDate(user.createdAt), true)
.addField(this.client.customEmojis.avatar + " " + message.translate("common:AVATAR"), user.displayAvatarURL({
size: 512,
dynamic: true,
format: "png"
}))
.setColor(data.config.embed.color)
.setFooter({
text: data.config.embed.footer
});
if (displayPresence) {
if (member.presence.activities[0].name === "Custom Status") {
embed.addField(this.client.customEmojis.games + " " + message.translate("common:GAME"), (member.presence.activities[0] ? `Пользовательский статус\n${member.presence.activities[0].state || message.translate("common:NOT_DEFINED")}` : message.translate("general/userinfo:NO_GAME")), true);
embed.addField(this.client.customEmojis.status[member.presence.status] + " " + message.translate("common:STATUS"), message.translate("common:STATUS_" + (member.presence.status.toUpperCase())), true);
} else {
embed.addField(this.client.customEmojis.games + " " + message.translate("common:GAME"), (member.presence.activities[0] ? `${member.presence.activities[0].name}\n${member.presence.activities[0].details}\n${member.presence.activities[0].state}` : message.translate("general/userinfo:NO_GAME")), true);
embed.addField(this.client.customEmojis.status[member.presence.status] + " " + message.translate("common:STATUS"), message.translate("common:STATUS_" + (member.presence.status.toUpperCase())), true);
}
}
if (member) {
// embed.addField(this.client.customEmojis.up + " " + message.translate("general/userinfo:ROLE"), (member.roles.highest ? member.roles.highest : message.translate("general/userinfo:NO_ROLE")), true)
embed.addField(this.client.customEmojis.calendar2 + " " + message.translate("common:JOIN"), this.client.printDate(member.joinedAt), true);
embed.addField(this.client.customEmojis.color + " " + message.translate("common:COLOR"), member.displayHexColor, true);
embed.addField(this.client.customEmojis.pencil + " " + message.translate("common:NICKNAME"), (member.nickname ? member.nickname : message.translate("general/userinfo:NO_NICKNAME")), true);
embed.addField(this.client.customEmojis.roles + " " + message.translate("common:ROLES"), (member.roles.size > 10 ? member.roles.cache.map((r) => r).slice(0, 9).join(", ") + " " + message.translate("general/userinfo:MORE_ROLES", {
count: member.roles.cache.size - 10
}) : (member.roles.cache.size < 1) ? message.translate("general/userinfo:NO_ROLE") : member.roles.cache.map((r) => r).join(", ")));
}
message.reply({
embeds: [embed]
});
}
}
module.exports = Userinfo;