cardboardbox/commands/Information/userinfo.js

92 lines
2.7 KiB
JavaScript
Raw Normal View History

2020-01-11 02:08:53 +00:00
const dateFormat = require('dateformat');
dateFormat('dddd, mmmm dS, yyyy, h:MM:ss TT');
exports.run = async (client, message, args, level) => {
let user = message.mentions.users.first() || message.author;
let member = message.guild.member(user);
2020-01-10 18:52:40 +00:00
if (!member) {
message.delete();
return (await message.reply("that member could not be found!")).delete(5000);
}
const millisCreated = new Date().getTime() - user.createdAt.getTime();
const daysCreated = millisCreated / 1000 / 60 / 60 / 24;
const millisJoined = new Date().getTime() - member.joinedAt.getTime();
const daysJoined = millisJoined / 1000 / 60 / 60 / 24;
2020-01-10 18:52:40 +00:00
let roles = member.roles.array().slice(1).sort((a, b) => a.comparePositionTo(b)).reverse().map(role => role.name);
2020-01-11 02:08:53 +00:00
if (roles.length < 1) roles = ['None'];
2020-01-10 18:52:40 +00:00
let game = (user.presence.game && user.presence.game && user.presence.game.name) || 'Not playing a game.'
await message.delete();
message.channel.send({ embed: client.embed(
2020-01-11 02:08:53 +00:00
`User info: ${member.user.tag}`,
"**This message will be deleted in 60 seconds.** :bomb:",
[
{
name: "= Status =",
value: `${user.presence.status[0].toUpperCase() + user.presence.status.slice(1)}`
},
{
name: "= Game =",
value: `${(user.presence.game && user.presence.game && user.presence.game.name) || 'Not playing a game.'}`
},
{
name: "= Nickname =",
2020-01-11 02:08:53 +00:00
value: member.nickname || "None"
},
{
name: "= Unique User ID (UUID) =",
2020-01-11 02:08:53 +00:00
value: member.user.id !== null ? member.user.id : "Unknown"
},
{
name: "= Account Creation Date =",
2020-01-11 02:08:53 +00:00
value: dateFormat(user.createdAt) !== null ? dateFormat(user.createdAt) : "Unknown"
},
{
name: "= Days Since Creation =",
2020-01-11 02:08:53 +00:00
value: daysCreated.toFixed(0) !== null ? daysCreated.toFixed(0) : "Unknown"
},
{
name: "= Server Join Date =",
2020-01-11 02:08:53 +00:00
value: member.joinedAt !== null ? member.joinedAt : "Unknown"
},
{
name: "= Days Since Joining =",
2020-01-11 02:08:53 +00:00
value: daysJoined.toFixed(0) !== null ? daysJoined.toFixed(0) : "Unknown"
},
{
name: "= Last Spoken =",
2020-01-11 02:08:53 +00:00
value: member.lastMessage !== null ? `**${member.lastMessage.createdAt}**, at server **${member.lastMessage.guild}**` : "Unknown"
},
{
name: "= User Roles =",
2020-01-11 02:08:53 +00:00
value: `\`${roles.join('\`, \`')}\``
}
],
{
inline: true,
2020-01-11 02:08:53 +00:00
footer: `Sent by ${message.author.tag}`,
footerIcon: message.author.avatarURL
2020-01-11 02:08:53 +00:00
})
})
};
exports.conf = {
enabled: true,
guildOnly: true,
2020-01-11 02:08:53 +00:00
aliases: ["user", "uinfo"],
permLevel: "User"
};
exports.help = {
name: "userinfo",
category: "Information",
description: "Gather information about a user, and returns the gathered stuff into an embed.",
usage: "userinfo [ping:self]"
};