JaBa/commands/General/userinfo.js

88 lines
4.6 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js"),
fetch = require("node-fetch");
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: 3000
2021-12-10 21:39:54 +05:00
});
}
async run (message, args, data) {
let displayPresence = true;
const isID = !isNaN(args[0]);
var user;
2021-12-11 01:11:50 +05:00
if (!args[0]) user = message.author;
if (message.mentions.users.first()) user = message.mentions.users.first();
if (isID && !user) {
2021-12-10 21:39:54 +05:00
user = this.client.users.cache.get(args[0]);
2021-12-11 01:11:50 +05:00
if (!user) {
2021-12-10 21:39:54 +05:00
user = await this.client.users.fetch(args[0], true).catch(() => {});
displayPresence = false;
2021-12-11 01:11:50 +05:00
};
};
if (!user) return message.error("general/userinfo:INVALID_USER");
2021-12-10 21:39:54 +05:00
let member = null;
2021-12-11 01:11:50 +05:00
if (message.guild) member = await message.guild.members.fetch(user).catch(() => {});
2021-12-10 21:39:54 +05:00
const embed = new Discord.MessageEmbed()
2021-12-24 20:52:27 +05:00
.setAuthor(user.tag, user.displayAvatarURL({ size: 512, dynamic: true, format: "png" }))
2021-12-10 21:39:54 +05:00
.setThumbnail(user.displayAvatarURL({ dynamic: true }))
2021-12-24 20:52:27 +05:00
.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"), message.printDate(user.createdAt), true)
.addField(this.client.customEmojis.avatar + " " + message.translate("common:AVATAR"), user.displayAvatarURL({ size: 512, dynamic: true, format: "png" }))
2021-12-10 21:39:54 +05:00
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer);
2021-12-11 01:11:50 +05:00
if (displayPresence) {
2021-12-24 20:52:27 +05:00
embed.addField(this.client.customEmojis.games + " " + message.translate("common:GAME"), (user.presence.activity ? user.presence.activity.name : message.translate("general/userinfo:NO_GAME")), true)
embed.addField(this.client.customEmojis.status.online + " " + message.translate("common:STATUS"), message.translate("common:STATUS_" + (user.presence.status.toUpperCase())), true);
2021-12-11 01:11:50 +05:00
};
if (member) {
2021-12-24 20:52:27 +05:00
embed.addField(this.client.customEmojis.up + " " + message.translate("common:ROLE"), (member.roles.highest ? member.roles.highest : message.translate("general/userinfo:NO_ROLE")), true)
embed.addField(this.client.customEmojis.calendar2 + " " + message.translate("common:JOIN"), message.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(", ")));
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
if (user.bot && this.client.config.apiKeys.dbl && (this.client.config.apiKeys.dbl !== "")) {
2021-12-24 20:52:27 +05:00
const res = await fetch("https://discordbots.org/api/bots/" + user.id, {
2021-12-10 21:39:54 +05:00
headers: { "Authorization": this.client.config.apiKeys.dbl }
});
const data = await res.json();
2021-12-11 01:11:50 +05:00
if (!data.error) {
2021-12-24 20:52:27 +05:00
embed.addField(this.client.customEmojis.desc + " " + message.translate("common:DESCRIPTION"), data.shortdesc, true)
.addField(this.client.customEmojis.stats + " " + message.translate("common:STATS"), message.translate("general/userinfo:BOT_STATS", {
2021-12-10 21:39:54 +05:00
votes: data.monthlyPoints || 0,
servers: data.server_count || 0,
shards: (data.shards || [0]).length,
lib: data.lib || "unknown"
}), true)
2021-12-24 20:52:27 +05:00
.addField(this.client.customEmojis.link + " " + message.translate("common:LINKS"), `${data.support ? `[${message.translate("common:SUPPORT")}](${data.support}) | ` : ""}${data.invite ? `[${message.translate("common:INVITE")}](${data.invite}) | ` : ""}${data.github ? `[GitHub](${data.github}) | ` : ""}${data.website ? `[${message.translate("common:WEBSITE")}](${data.website})` : ""}`, true);
2021-12-11 01:11:50 +05:00
};
};
2021-12-10 21:39:54 +05:00
message.channel.send(embed);
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
module.exports = Userinfo;