From 5888467bf540f19e433084c145716713bff5dd5b Mon Sep 17 00:00:00 2001 From: Anthony M <47640864+IDeletedSystem64@users.noreply.github.com> Date: Fri, 5 Feb 2021 22:17:07 -0600 Subject: [PATCH] userinfo --- commands/userinfo.js | 157 +++++++++++++++++++++++++++++-------------- 1 file changed, 107 insertions(+), 50 deletions(-) diff --git a/commands/userinfo.js b/commands/userinfo.js index 42ddd99..dd6c121 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -1,52 +1,109 @@ -const { User } = require("discord.js"); - module.exports = { - - name: 'userinfo', - description: 'Shows information about you or another user.', - execute(client, message, args) { - const taggedUser = message.mentions.users.first(); - + name: "userinfo", + description: "Get the information of a user.", + guildOnly: false, + authorizedGuilds: [], + hidden: false, + permissions: ["DEFAULT"], + cooldown: 2, + aliases: [ "user", "u" ], + syntax: [ + " " + ], + execute: async(client, message, args) => { + function fetchData(type, user, wasInCache) { - //Actual code - const embed = { - "title": "<:userinfo:793885335498522685> **User Information**", - "description": "Everything you've ever wanted to know about **" + taggedUser.username + ("!**"), - "color": 11038194, - - "footer": { - "icon_url": "https://cdn.discordapp.com/attachments/549707869138714635/793524910172667964/Screenshot_26.png", - "text": "Anitrox © IDeletedSystem64 2018-2021. All Rights Reserved" - }, - "thumbnail": { - "url": taggedUser.displayAvatarURL({ dynamic: true }) - }, - "fields": [ - { - "name": "<:userquestion:793984046912110633> **Full Username**", - "value": taggedUser.username + ("#") + taggedUser.discriminator - }, - { - "name": "<:userquestion:793984046912110633> User Status", - "value": taggedUser.status, - "value": taggedUser.presence - }, - { - "name": "<:userquestion:793984046912110633> User ID", - "value": taggedUser.id - }, - { - "name": "<:userquestion:793984046912110633> User Joined Discord", - "value": taggedUser.CreatedAt, - "inline": true - }, - { - "name": "<:userquestion:793984046912110633> User Joined Server", - "value": "tba", - "inline": true - } - ] - }; - message.channel.send({ embed }); - } - }; \ No newline at end of file + var embedFields = [ + { name: "Username", value: user.username, inline: true }, + { name: "Discriminator", value: user.discriminator, inline: true }, + { name: "Full Tag", value: (user.bot) ? user.tag + " **[BOT]**" : user.tag, inline: false }, + { name: "ID", value: user.id, inline: true }, + { name: "Joined Discord", value: user.createdAt, inline: true }, + { name: "Avatar", value: "Click/Tap **[HERE]("+user.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 })+")** for full size!", inline: false } + ]; + + var status = "Offline"; + var states = { + "offline": client.config.system.emotes.discord.offline + " **Offline**", + "idle": client.config.system.emotes.discord.idle + " **Idle**", + "dnd": client.config.system.emotes.discord.dnd + " **Do Not Disturb**", + "online": client.config.system.emotes.discord.online + " **Online**" + }; + + if (user.presence != "offline") { + status = states[user.presence.status]; + if (user.presence.activities.length > 0) { + for (var i=0;i 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); + }; + } +}; \ No newline at end of file