userinfo
This commit is contained in:
parent
0c1ced9859
commit
5888467bf5
|
@ -1,52 +1,109 @@
|
||||||
const { User } = require("discord.js");
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
name: "userinfo",
|
||||||
name: 'userinfo',
|
description: "Get the information of a user.",
|
||||||
description: 'Shows information about you or another user.',
|
guildOnly: false,
|
||||||
execute(client, message, args) {
|
authorizedGuilds: [],
|
||||||
const taggedUser = message.mentions.users.first();
|
hidden: false,
|
||||||
|
permissions: ["DEFAULT"],
|
||||||
|
cooldown: 2,
|
||||||
|
aliases: [ "user", "u" ],
|
||||||
|
syntax: [
|
||||||
|
" <UserID/@User>"
|
||||||
|
],
|
||||||
|
execute: async(client, message, args) => {
|
||||||
|
function fetchData(type, user, wasInCache) {
|
||||||
|
|
||||||
//Actual code
|
var embedFields = [
|
||||||
const embed = {
|
{ name: "Username", value: user.username, inline: true },
|
||||||
"title": "<:userinfo:793885335498522685> **User Information**",
|
{ name: "Discriminator", value: user.discriminator, inline: true },
|
||||||
"description": "Everything you've ever wanted to know about **" + taggedUser.username + ("!**"),
|
{ name: "Full Tag", value: (user.bot) ? user.tag + " **[BOT]**" : user.tag, inline: false },
|
||||||
"color": 11038194,
|
{ name: "ID", value: user.id, inline: true },
|
||||||
|
{ name: "Joined Discord", value: user.createdAt, inline: true },
|
||||||
"footer": {
|
{ name: "Avatar", value: "Click/Tap **[HERE]("+user.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 })+")** for full size!", inline: false }
|
||||||
"icon_url": "https://cdn.discordapp.com/attachments/549707869138714635/793524910172667964/Screenshot_26.png",
|
];
|
||||||
"text": "Anitrox © IDeletedSystem64 2018-2021. All Rights Reserved"
|
|
||||||
},
|
var status = "Offline";
|
||||||
"thumbnail": {
|
var states = {
|
||||||
"url": taggedUser.displayAvatarURL({ dynamic: true })
|
"offline": client.config.system.emotes.discord.offline + " **Offline**",
|
||||||
},
|
"idle": client.config.system.emotes.discord.idle + " **Idle**",
|
||||||
"fields": [
|
"dnd": client.config.system.emotes.discord.dnd + " **Do Not Disturb**",
|
||||||
{
|
"online": client.config.system.emotes.discord.online + " **Online**"
|
||||||
"name": "<:userquestion:793984046912110633> **Full Username**",
|
};
|
||||||
"value": taggedUser.username + ("#") + taggedUser.discriminator
|
|
||||||
},
|
if (user.presence != "offline") {
|
||||||
{
|
status = states[user.presence.status];
|
||||||
"name": "<:userquestion:793984046912110633> User Status",
|
if (user.presence.activities.length > 0) {
|
||||||
"value": taggedUser.status,
|
for (var i=0;i<user.presence.activities.length;i++) {
|
||||||
"value": taggedUser.presence
|
var activity = user.presence.activities[i];
|
||||||
},
|
if (activity.type == "CUSTOM_STATUS")
|
||||||
{
|
status += "\n**" + activity.name + "** " + activity.state;
|
||||||
"name": "<:userquestion:793984046912110633> User ID",
|
else
|
||||||
"value": taggedUser.id
|
status += "\n**" + activity.type + "** " + activity.name;
|
||||||
},
|
};
|
||||||
{
|
};
|
||||||
"name": "<:userquestion:793984046912110633> User Joined Discord",
|
};
|
||||||
"value": taggedUser.CreatedAt,
|
|
||||||
"inline": true
|
embedFields.push({ name: "Presence", value: status });
|
||||||
},
|
|
||||||
{
|
if (!wasInCache)
|
||||||
"name": "<:userquestion:793984046912110633> User Joined Server",
|
embedFields.unshift({ name: "Hold up!", value: "This user has never been seen by this bot.\nSome information may be inaccurate." });
|
||||||
"value": "tba",
|
|
||||||
"inline": true
|
if (message.guild) {
|
||||||
}
|
if (message.guild.members.cache.get(user.id) != null) {
|
||||||
]
|
if (message.guild.members.cache.get(user.id).nickname != null)
|
||||||
};
|
embedFields.push({ name: "Nickname", value: message.guild.members.cache.get(user.id).nickname });
|
||||||
message.channel.send({ embed });
|
if (message.guild.members.cache.get(user.id).roles.cache.array().length > 1)
|
||||||
}
|
embedFields.push({ name: "Roles", value: message.guild.members.cache.get(user.id).roles.cache.array().sort((a, b) => a.comparePositionTo(b)).reverse().map(role => role).join(" ").replace("@"+"everyone", "") }); // Thanks to Nooooah#9507
|
||||||
};
|
else
|
||||||
|
embedFields.push({ name: "Roles", value: "User has no roles.. :<" });
|
||||||
|
|
||||||
|
function getJoinPosition(ID) {
|
||||||
|
var memberJoins = message.guild.members.cache.array().sort((a, b) => a.joinedAt - b.joinedAt);
|
||||||
|
for (var i = 0; i < memberJoins.length; i++){ if (memberJoins[i].id == ID) return i; } ;
|
||||||
|
};
|
||||||
|
|
||||||
|
embedFields.push(
|
||||||
|
{ name: "Joined Server", value: new Date(message.guild.members.cache.get(user.id).joinedAt).toString(), inline: true },
|
||||||
|
{ name: "Join Position", value: (getJoinPosition(user.id) + 1), inline: true }
|
||||||
|
);
|
||||||
|
} else { };
|
||||||
|
};
|
||||||
|
|
||||||
|
var embed = { embed: {
|
||||||
|
thumbnail: { url: user.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }) },
|
||||||
|
title: client.config.system.emotes.information + " **User Information**",
|
||||||
|
color: client.config.system.embedColors.lime,
|
||||||
|
fields: embedFields,
|
||||||
|
footer: { text: client.config.system.footerText }
|
||||||
|
}};
|
||||||
|
|
||||||
|
return embed;
|
||||||
|
};
|
||||||
|
|
||||||
|
var userToGet = message.author.id, gotData = null;
|
||||||
|
try {
|
||||||
|
if (args[0] != null) {
|
||||||
|
userToGet = args[0].replace(/[<@!>]/g, '');
|
||||||
|
};
|
||||||
|
var wasInCache = client.users.cache.get(userToGet) || false;
|
||||||
|
|
||||||
|
await client.users.fetch(userToGet).then(function(user) {
|
||||||
|
gotData = fetchData("user", user, wasInCache);
|
||||||
|
});
|
||||||
|
|
||||||
|
message.channel.send(gotData);
|
||||||
|
} catch (Ex) {
|
||||||
|
var embed = { embed: {
|
||||||
|
title: client.config.system.emotes.error + " **User Information**",
|
||||||
|
color: client.config.system.embedColors.red,
|
||||||
|
footer: { text: client.config.system.footerText }
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (Ex.message.includes("Unknown User"))
|
||||||
|
embed.embed.description = "**That user does not exist!**\nCheck the ID and/or ping and try again.";
|
||||||
|
else
|
||||||
|
embed.embed.fields = [ { name: "Error! Error!", value: "```js\n" + Ex.stack + "```" } ];
|
||||||
|
message.channel.send(embed);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
Reference in New Issue