woomy-v2/bot/commands/Utility/userinfo.js

74 lines
3 KiB
JavaScript
Raw Normal View History

2021-03-03 08:20:16 +00:00
const dayjs = require('dayjs');
dayjs.extend(require('dayjs/plugin/relativeTime'));
module.exports = class {
constructor (name, category) {
this.name = name,
this.category = category,
this.enabled = true,
this.devOnly = false,
this.aliases = [],
this.userPerms = [],
this.botPerms = [],
this.cooldown = 2000,
this.help = {
description: '',
arguments: '',
details: '',
examples: ''
};
}
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
let member = message.member;
if (args[0]) {
if (message.mentions.length > 0) {
2021-03-04 01:29:21 +00:00
member = await client.functions.getMember(message.channel.guild, message.mentions[0].id);
2021-03-03 08:20:16 +00:00
} else {
member = await message.channel.guild.searchMembers(args.join(' '), 2);
2021-03-04 01:29:21 +00:00
if (member.length === 0) return message.channel.createMessage(
2021-03-03 08:20:16 +00:00
`${client.emojis.userError} No users found. Check for mispellings, or ping the user instead.`
);
if (member.length > 1) return message.channel.createMessage(
`${client.emojis.userError} Found more than one user, try refining your search or pinging the user instead.`
);
member = member[0];
}
}
2021-03-04 01:29:21 +00:00
const badges = [];
if (client.config.ownerIDs.includes(member.id)) badges.push('<:Woomy_Developer:816822318289518622> ');
if (member.id === member.guild.ownerID) badges.push('<:owner:685703193694306331>');
if (member.bot) badges.push('<:bot:686489601678114859>');
const roles = [];
for (const roleID of member.roles) {
if (roles.length === 45) {
roles.push(`and ${member.roles.length - 45} more`);
break;
}
roles.push(`<@&${roleID}>`);
}
2021-03-03 08:20:16 +00:00
const embed = new client.RichEmbed()
.setTitle(member.user.username + '#' + member.user.discriminator)
2021-03-04 01:29:21 +00:00
.setColour(client.functions.displayHexColour(message.channel.guild, member))
2021-03-03 08:20:16 +00:00
.setThumbnail(member.user.avatarURL || member.user.defaultAvatarURL)
.addField('Display Name', member.nick || member.user.username, true)
.addField('User ID', member.id, true)
2021-03-04 01:29:21 +00:00
.addField('Highest Role', `<@&${client.functions.highestRole(member).id}>`, true)
.addField('Roles:', roles.join(' '))
.addField('Joined Server', `${dayjs(member.joinedAt).format('D/M/YYYY HH:mm (UTCZ)')}\n*${dayjs().to(member.joinedAt)}*`, true)
2021-03-03 08:20:16 +00:00
.addField('Joined Discord', `${dayjs(member.user.createdAt).format('D/M/YYYY HH:mm (UTCZ)')}\n*${dayjs().to(member.user.createdAt)}*`, true);
2021-03-04 01:29:21 +00:00
if (badges.length > 0) embed.setDescription(badges.join(' '));
2021-03-03 08:20:16 +00:00
message.channel.createMessage({ embed: embed });
}
};