2020-04-14 19:02:12 -04:00
|
|
|
/* eslint-disable no-bitwise */
|
|
|
|
import moment from 'moment';
|
2020-04-16 23:29:17 -04:00
|
|
|
import { Message, Member } from 'eris';
|
2020-04-14 19:02:12 -04:00
|
|
|
import { Client, Command, RichEmbed } from '../class';
|
|
|
|
import acknowledgements from '../configs/acknowledgements.json';
|
2020-04-14 21:19:00 -04:00
|
|
|
import { whois as emotes } from '../configs/emotes.json';
|
2020-04-14 19:02:12 -04:00
|
|
|
|
|
|
|
export default class Whois extends Command {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super(client);
|
|
|
|
this.name = 'whois';
|
|
|
|
this.description = 'Provides information on a member.';
|
2020-04-15 15:33:46 -04:00
|
|
|
this.usage = 'whois [member]';
|
2020-04-14 19:02:12 -04:00
|
|
|
this.permissions = 0;
|
|
|
|
this.guildOnly = true;
|
|
|
|
this.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async run(message: Message, args: string[]) {
|
2020-04-14 21:33:47 -04:00
|
|
|
try {
|
|
|
|
let member: Member;
|
|
|
|
if (!args[0]) member = message.member;
|
|
|
|
else {
|
2020-06-09 18:19:20 -04:00
|
|
|
member = this.client.util.resolveMember(args.join(' '), message.guild);
|
2020-04-16 22:56:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!member) {
|
|
|
|
return this.error(message.channel, 'Member not found.');
|
2020-04-14 21:33:47 -04:00
|
|
|
}
|
|
|
|
const embed = new RichEmbed();
|
|
|
|
embed.setAuthor(`${member.user.username}#${member.user.discriminator}`, member.user.avatarURL);
|
2020-04-16 09:58:06 -04:00
|
|
|
/* if (member.roles.includes('453689940140883988')) {
|
2020-04-14 21:33:47 -04:00
|
|
|
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_associate-badge.png');
|
|
|
|
} else if (member.roles.includes('455972169449734144')) {
|
|
|
|
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_sheriff-badge.png');
|
|
|
|
} else if (member.roles.includes('662163685439045632')) {
|
|
|
|
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_marshal-badge.png');
|
|
|
|
} else {
|
|
|
|
embed.setThumbnail(member.avatarURL);
|
2020-04-16 09:58:06 -04:00
|
|
|
} */
|
2020-04-16 09:59:14 -04:00
|
|
|
embed.setThumbnail(member.avatarURL);
|
2020-04-14 21:33:47 -04:00
|
|
|
const ackResolve = this.resolveStaffInformation(member.id);
|
|
|
|
let description = '';
|
2020-05-21 02:28:04 -04:00
|
|
|
if (ackResolve?.title) {
|
|
|
|
description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__\n\n`;
|
|
|
|
}
|
|
|
|
if (ackResolve?.emailAddress) {
|
|
|
|
description += `${emotes.email} ${ackResolve.emailAddress}\n`;
|
|
|
|
}
|
|
|
|
if (ackResolve?.gitlab) {
|
|
|
|
description += `${emotes.gitlab} ${ackResolve.gitlab}\n`;
|
|
|
|
}
|
|
|
|
if (ackResolve?.github) {
|
|
|
|
description += `${emotes.github} ${ackResolve.github}\n`;
|
|
|
|
}
|
|
|
|
if (ackResolve?.bio) {
|
|
|
|
description += `${emotes.bio} *${ackResolve.bio}*\n`;
|
2020-04-14 21:33:47 -04:00
|
|
|
}
|
|
|
|
description += `\n<@${member.id}>`;
|
|
|
|
embed.setDescription(description);
|
2020-04-16 22:56:52 -04:00
|
|
|
|
2020-06-09 18:19:20 -04:00
|
|
|
for (const role of member.roles.map((r) => message.guild.roles.get(r)).sort((a, b) => b.position - a.position)) {
|
2020-04-17 12:44:17 -04:00
|
|
|
if (role?.color !== 0) {
|
|
|
|
embed.setColor(role.color);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-05-22 02:11:00 -04:00
|
|
|
if (member.status) {
|
|
|
|
embed.addField('Status', `${member.status[0].toUpperCase()}${member.status.slice(1)}`, true);
|
|
|
|
}
|
2020-04-24 18:57:56 -04:00
|
|
|
if (member.bot) {
|
|
|
|
embed.addField('Platform', 'API/WebSocket', true);
|
2020-04-25 16:24:09 -04:00
|
|
|
} else if (member.clientStatus?.web === 'online' || member.clientStatus?.web === 'idle' || member.clientStatus?.web === 'dnd') {
|
2020-04-24 18:57:56 -04:00
|
|
|
embed.addField('Platform', 'Web', true);
|
2020-04-25 16:24:09 -04:00
|
|
|
} else if (member.clientStatus?.desktop === 'online' || member.clientStatus?.desktop === 'idle' || member.clientStatus?.desktop === 'dnd') {
|
2020-04-24 18:57:56 -04:00
|
|
|
embed.addField('Platform', 'Desktop', true);
|
2020-04-25 16:24:09 -04:00
|
|
|
} else if (member.clientStatus?.mobile === 'online' || member.clientStatus?.mobile === 'idle' || member.clientStatus?.mobile === 'dnd') {
|
2020-04-24 18:57:56 -04:00
|
|
|
embed.addField('Platform', 'Mobile', true);
|
|
|
|
}
|
2020-04-17 12:47:26 -04:00
|
|
|
embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
|
|
|
embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
|
|
|
if (member.roles.length > 0) {
|
2020-06-09 18:19:20 -04:00
|
|
|
embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => message.guild.roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', '));
|
2020-04-17 12:44:17 -04:00
|
|
|
}
|
2020-04-14 21:33:47 -04:00
|
|
|
const permissions: string[] = [];
|
2020-04-16 09:53:33 -04:00
|
|
|
const serverAcknowledgements: string[] = [];
|
2020-04-14 21:33:47 -04:00
|
|
|
const bit = member.permission.allow;
|
2020-06-09 18:19:20 -04:00
|
|
|
if (message.guild.ownerID === member.id) serverAcknowledgements.push('Server Owner');
|
2020-04-16 09:53:33 -04:00
|
|
|
if ((bit | 8) === bit) { permissions.push('Administrator'); serverAcknowledgements.push('Server Admin'); }
|
2020-05-01 00:41:13 -04:00
|
|
|
if ((bit | 32) === bit) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); }
|
|
|
|
if ((bit | 16) === bit) permissions.push('Manage Channels');
|
2020-04-14 21:33:47 -04:00
|
|
|
if ((bit | 268435456) === bit) permissions.push('Manage Roles');
|
2020-04-16 09:53:33 -04:00
|
|
|
if ((bit | 8192) === bit) { permissions.push('Manage Messages'); serverAcknowledgements.push('Server Moderator'); }
|
2020-04-14 21:33:47 -04:00
|
|
|
if ((bit | 134217728) === bit) permissions.push('Manage Nicknames');
|
|
|
|
if ((bit | 1073741824) === bit) permissions.push('Manage Emojis');
|
|
|
|
if ((bit | 4) === bit) permissions.push('Ban Members');
|
|
|
|
if ((bit | 2) === bit) permissions.push('Kick Members');
|
2020-05-16 15:03:21 -04:00
|
|
|
const account = await this.client.db.Member.findOne({ userID: member.id });
|
2020-04-24 23:47:07 -04:00
|
|
|
if (account?.additional?.langs.length > 0) {
|
|
|
|
const langs: string[] = [];
|
2020-04-25 00:39:47 -04:00
|
|
|
for (const lang of account.additional.langs.sort((a, b) => a.localeCompare(b))) {
|
2020-04-24 23:47:07 -04:00
|
|
|
switch (lang) {
|
|
|
|
case 'asm':
|
|
|
|
langs.push('<:AssemblyLanguage:703448714248716442> Assembly Language');
|
|
|
|
break;
|
|
|
|
case 'cfam':
|
|
|
|
langs.push('<:clang:553684262193332278> C/C++');
|
|
|
|
break;
|
2020-04-25 00:33:08 -04:00
|
|
|
case 'csharp':
|
|
|
|
langs.push('<:csharp:553684277280112660> C#');
|
|
|
|
break;
|
2020-04-24 23:47:07 -04:00
|
|
|
case 'go':
|
|
|
|
langs.push('<:Go:703449475405971466> Go');
|
|
|
|
break;
|
|
|
|
case 'java':
|
|
|
|
langs.push('<:Java:703449725181100135> Java');
|
|
|
|
break;
|
|
|
|
case 'js':
|
|
|
|
langs.push('<:JavaScriptECMA:703449987916496946> JavaScript');
|
|
|
|
break;
|
|
|
|
case 'kt':
|
|
|
|
langs.push('<:Kotlin:703450201838321684> Kotlin');
|
|
|
|
break;
|
|
|
|
case 'py':
|
|
|
|
langs.push('<:python:553682965482176513> Python');
|
|
|
|
break;
|
|
|
|
case 'rb':
|
|
|
|
langs.push('<:ruby:604812470451699712> Ruby');
|
|
|
|
break;
|
|
|
|
case 'rs':
|
|
|
|
langs.push('<:Rust:703450901960196206> Rust');
|
|
|
|
break;
|
|
|
|
case 'swift':
|
|
|
|
langs.push('<:Swift:703451096093294672> Swift');
|
|
|
|
break;
|
|
|
|
case 'ts':
|
|
|
|
langs.push('<:TypeScript:703451285789343774> TypeScript');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
embed.addField('Known Languages', langs.join(', '));
|
|
|
|
}
|
2020-05-06 17:05:50 -04:00
|
|
|
if (account?.additional?.operatingSystems.length > 0) {
|
|
|
|
const operatingSystems: string[] = [];
|
|
|
|
for (const os of account.additional.operatingSystems.sort((a, b) => a.localeCompare(b))) {
|
|
|
|
switch (os) {
|
|
|
|
case 'arch':
|
|
|
|
operatingSystems.push('<:arch:707694976523304960> Arch');
|
|
|
|
break;
|
|
|
|
case 'deb':
|
|
|
|
operatingSystems.push('<:debian:707695042617147589> Debian');
|
|
|
|
break;
|
2020-05-06 17:17:40 -04:00
|
|
|
case 'cent':
|
|
|
|
operatingSystems.push('<:centos:707702165816213525> CentOS');
|
|
|
|
break;
|
2020-05-06 17:05:50 -04:00
|
|
|
case 'fedora':
|
|
|
|
operatingSystems.push('<:fedora:707695073151680543> Fedora');
|
|
|
|
break;
|
2020-05-06 17:14:51 -04:00
|
|
|
case 'manjaro':
|
|
|
|
operatingSystems.push('<:manjaro:707701473680556062> Manjaro');
|
|
|
|
break;
|
2020-05-06 17:05:50 -04:00
|
|
|
case 'mdarwin':
|
|
|
|
operatingSystems.push('<:mac:707695427754917919> macOS');
|
|
|
|
break;
|
|
|
|
case 'redhat':
|
|
|
|
operatingSystems.push('<:redhat:707695102159749271> RedHat Enterprise Linux');
|
|
|
|
break;
|
|
|
|
case 'ubuntu':
|
|
|
|
operatingSystems.push('<:ubuntu:707695136888586300> Ubuntu');
|
|
|
|
break;
|
|
|
|
case 'win':
|
|
|
|
operatingSystems.push('<:windows10:707695160259248208> Windows');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
embed.addField('Used Operating Systems', operatingSystems.join(', '));
|
|
|
|
}
|
2020-04-14 21:33:47 -04:00
|
|
|
if (permissions.length > 0) {
|
|
|
|
embed.addField('Permissions', permissions.join(', '));
|
2020-04-14 19:02:12 -04:00
|
|
|
}
|
2020-04-16 09:53:33 -04:00
|
|
|
if (serverAcknowledgements.length > 0) {
|
|
|
|
embed.addField('Acknowledgements', serverAcknowledgements[0]);
|
|
|
|
}
|
2020-04-17 12:33:03 -04:00
|
|
|
if (ackResolve?.acknowledgements) {
|
2020-04-14 21:33:47 -04:00
|
|
|
embed.addField('Bot Acknowledgements', ackResolve.acknowledgements.join(', '));
|
|
|
|
}
|
|
|
|
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
|
|
|
embed.setTimestamp();
|
|
|
|
return message.channel.createMessage({ embed });
|
|
|
|
} catch (err) {
|
|
|
|
return this.client.util.handleError(err, message, this);
|
2020-04-14 19:02:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public resolveStaffInformation(id: string) {
|
2020-04-16 22:56:52 -04:00
|
|
|
return acknowledgements.find((m) => m.id === id);
|
2020-04-14 19:02:12 -04:00
|
|
|
}
|
|
|
|
}
|