remove discriminator part on whois

merge-requests/28/head
Damian Freeman 2023-07-21 01:05:44 +00:00
parent 77213c0178
commit 6b4a3c3a55
1 changed files with 238 additions and 238 deletions

View File

@ -1,238 +1,238 @@
/* eslint-disable no-bitwise */ /* eslint-disable no-bitwise */
import moment from 'moment'; import moment from 'moment';
import { Member } from 'eris'; import { Member } from 'eris';
import { Client, CmdContext, Command, RichEmbed } from '../class'; import { Client, CmdContext, Command, RichEmbed } from '../class';
import { whois as emotes } from '../configs/emotes.json'; import { whois as emotes } from '../configs/emotes.json';
export default class Whois extends Command { export default class Whois extends Command {
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
this.name = 'whois'; this.name = 'whois';
this.description = 'Provides information on a member.'; this.description = 'Provides information on a member.';
this.usage = 'whois [member]'; this.usage = 'whois [member]';
this.permissions = 0; this.permissions = 0;
this.guildOnly = true; this.guildOnly = true;
this.enabled = true; this.enabled = true;
} }
public memberPostNominals(member: Member): string[] | false { public memberPostNominals(member: Member): string[] | false {
const arr = []; const arr = [];
if (member.roles.includes('858049948401401866')) arr.push('RCA'); if (member.roles.includes('858049948401401866')) arr.push('RCA');
if (member.roles.includes('506943223680466955')) arr.push('PRF-C'); if (member.roles.includes('506943223680466955')) arr.push('PRF-C');
if (arr.length <= 0) return false; if (arr.length <= 0) return false;
return arr; return arr;
} }
public async run(ctx: CmdContext) { public async run(ctx: CmdContext) {
let member: Member; let member: Member;
if (!ctx.args[0]) member = ctx.message.member; if (!ctx.args[0]) member = ctx.message.member;
else { else {
member = this.client.util.resolveMember(ctx.args.join(' '), this.mainGuild); member = this.client.util.resolveMember(ctx.args.join(' '), this.mainGuild);
try { try {
if (!member) member = await this.mainGuild.getRESTMember(ctx.args[0]); if (!member) member = await this.mainGuild.getRESTMember(ctx.args[0]);
} catch { } catch {
return this.error(ctx.message.channel, 'Member not found.'); return this.error(ctx.message.channel, 'Member not found.');
} }
} }
if (!member) { if (!member) {
return this.error(ctx.message.channel, 'Member not found.'); return this.error(ctx.message.channel, 'Member not found.');
} }
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setThumbnail(member.avatarURL); embed.setThumbnail(member.avatarURL);
const ackResolve = await this.client.db.mongo.Staff.findOne({ userID: member.id }).lean().exec(); const ackResolve = await this.client.db.mongo.Staff.findOne({ userID: member.id }).lean().exec();
const mpn = this.memberPostNominals(member); const mpn = this.memberPostNominals(member);
let title = `${member.user.username}#${member.user.discriminator}`; let title = `${member.user.username}`;
if (!ackResolve && mpn) { if (!ackResolve && mpn) {
title += `, ${mpn.join(', ')}`; title += `, ${mpn.join(', ')}`;
} }
if (ackResolve?.isManager) title += ' [k]'; if (ackResolve?.isManager) title += ' [k]';
embed.setAuthor(title, member.user.avatarURL); embed.setAuthor(title, member.user.avatarURL);
let description = ''; let description = '';
let titleAndDepartment = ''; let titleAndDepartment = '';
if (ackResolve?.title && ackResolve?.dept) { if (ackResolve?.title && ackResolve?.dept) {
titleAndDepartment += `${emotes.titleAndDepartment} __**${ackResolve.title}**__, __${ackResolve.dept}__\n\n`; titleAndDepartment += `${emotes.titleAndDepartment} __**${ackResolve.title}**__, __${ackResolve.dept}__\n\n`;
} else if (ackResolve?.dept) { } else if (ackResolve?.dept) {
titleAndDepartment += `${emotes.titleAndDepartment} __${ackResolve.dept}__\n\n`; titleAndDepartment += `${emotes.titleAndDepartment} __${ackResolve.dept}__\n\n`;
} }
if (titleAndDepartment.length > 0) description += titleAndDepartment; if (titleAndDepartment.length > 0) description += titleAndDepartment;
if (ackResolve?.emailAddress) { if (ackResolve?.emailAddress) {
description += `${emotes.email} ${ackResolve.emailAddress}\n`; description += `${emotes.email} ${ackResolve.emailAddress}\n`;
} }
const memberProfile = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec(); const memberProfile = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec();
if (memberProfile?.additional?.gitlab) { if (memberProfile?.additional?.gitlab) {
description += `${emotes.gitlab} ${memberProfile?.additional.gitlab}\n`; description += `${emotes.gitlab} ${memberProfile?.additional.gitlab}\n`;
} }
if (memberProfile?.additional?.github) { if (memberProfile?.additional?.github) {
description += `${emotes.github} ${memberProfile?.additional.github}\n`; description += `${emotes.github} ${memberProfile?.additional.github}\n`;
} }
if (memberProfile?.additional?.bio) { if (memberProfile?.additional?.bio) {
description += `${emotes.bio} *${memberProfile?.additional.bio}*\n`; description += `${emotes.bio} *${memberProfile?.additional.bio}*\n`;
} }
description += `\n<@${member.id}>`; description += `\n<@${member.id}>`;
embed.setDescription(description); embed.setDescription(description);
for (const role of member.roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) { for (const role of member.roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
if (role?.color !== 0) { if (role?.color !== 0) {
embed.setColor(role.color); embed.setColor(role.color);
break; break;
} }
} }
embed.addField('Status', member.status === 'dnd' ? 'Do Not Disturb' : this.client.util.capsFirstLetter(member.status) || 'Offline', true); embed.addField('Status', member.status === 'dnd' ? 'Do Not Disturb' : this.client.util.capsFirstLetter(member.status) || 'Offline', true);
embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); 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); embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
const score = await this.client.db.mongo.Score.findOne({ userID: member.id }).lean().exec(); const score = await this.client.db.mongo.Score.findOne({ userID: member.id }).lean().exec();
if (score) { if (score) {
await this.client.report.createInquiry(member.id, 'Library of Code sp-us | Bureau of Community Reports', 1); await this.client.report.createInquiry(member.id, 'Library of Code sp-us | Bureau of Community Reports', 1);
let totalScore = '0'; let totalScore = '0';
if (score.total < 200) totalScore = '---'; if (score.total < 200) totalScore = '---';
else if (score.total > 800) totalScore = '800'; else if (score.total > 800) totalScore = '800';
else totalScore = `${score.total}`; else totalScore = `${score.total}`;
embed.addField('CommScore™', totalScore, true); embed.addField('CommScore™', totalScore, true);
} else embed.addField('CommScore™', 'N/C', true); } else embed.addField('CommScore™', 'N/C', true);
if (member.roles.length > 0) { if (member.roles.length > 0) {
embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', ')); embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', '));
} }
const flags: string[] = []; const flags: string[] = [];
if (member.user.publicFlags) { if (member.user.publicFlags) {
if ((member.user.publicFlags & (1 << 12)) === 1 << 12) flags.push('<:System:768370601265201152>'); if ((member.user.publicFlags & (1 << 12)) === 1 << 12) flags.push('<:System:768370601265201152>');
if ((member.user.publicFlags & (1 << 0)) === 1 << 0) flags.push('<:DiscordStaff:768370601882025985>'); if ((member.user.publicFlags & (1 << 0)) === 1 << 0) flags.push('<:DiscordStaff:768370601882025985>');
if ((member.user.publicFlags & (1 << 1)) === 1 << 1) flags.push('<:Partnered:768370601395879936>'); if ((member.user.publicFlags & (1 << 1)) === 1 << 1) flags.push('<:Partnered:768370601395879936>');
if ((member.user.publicFlags & (1 << 3)) === 1 << 3) flags.push('<:BugHunter:768370601105555467>'); if ((member.user.publicFlags & (1 << 3)) === 1 << 3) flags.push('<:BugHunter:768370601105555467>');
if ((member.user.publicFlags & (1 << 14)) === 1 << 14) flags.push('<:BugHunter:768370601105555467>'); if ((member.user.publicFlags & (1 << 14)) === 1 << 14) flags.push('<:BugHunter:768370601105555467>');
if ((member.user.publicFlags & (1 << 2)) === 1 << 2) flags.push('<:HypeSquadEvents:768370600745762846>'); if ((member.user.publicFlags & (1 << 2)) === 1 << 2) flags.push('<:HypeSquadEvents:768370600745762846>');
if ((member.user.publicFlags & (1 << 6)) === 1 << 6) flags.push('<:HypeSquadBravery:768370601328640011> '); if ((member.user.publicFlags & (1 << 6)) === 1 << 6) flags.push('<:HypeSquadBravery:768370601328640011> ');
if ((member.user.publicFlags & (1 << 7)) === 1 << 7) flags.push('<:HypeSquadBrilliance:768370600842362900>'); if ((member.user.publicFlags & (1 << 7)) === 1 << 7) flags.push('<:HypeSquadBrilliance:768370600842362900>');
if ((member.user.publicFlags & (1 << 8)) === 1 << 8) flags.push('<:HypeSquadBalance:768370599584071751> '); if ((member.user.publicFlags & (1 << 8)) === 1 << 8) flags.push('<:HypeSquadBalance:768370599584071751> ');
if ((member.user.publicFlags & (1 << 9)) === 1 << 9) flags.push('<:EarlySupporter:768370601873768468>'); if ((member.user.publicFlags & (1 << 9)) === 1 << 9) flags.push('<:EarlySupporter:768370601873768468>');
if ((member.user.publicFlags & (1 << 16)) === 1 << 16) flags.push('<:VerifiedBot:768370599252197396>'); if ((member.user.publicFlags & (1 << 16)) === 1 << 16) flags.push('<:VerifiedBot:768370599252197396>');
if ((member.user.publicFlags & (1 << 17)) === 1 << 17) flags.push('<:VerifiedBotDeveloper:768370601701933077>'); if ((member.user.publicFlags & (1 << 17)) === 1 << 17) flags.push('<:VerifiedBotDeveloper:768370601701933077>');
} }
if (flags.length > 0) embed.addField('Flags', flags.join(' ')); if (flags.length > 0) embed.addField('Flags', flags.join(' '));
const permissions: string[] = []; const permissions: string[] = [];
const serverAcknowledgements: string[] = []; const serverAcknowledgements: string[] = [];
const bit = Number(member.permissions.allow); const bit = Number(member.permissions.allow);
if (this.mainGuild.ownerID === member.id) serverAcknowledgements.push('Server Owner'); if (this.mainGuild.ownerID === member.id) serverAcknowledgements.push('Server Owner');
if (bit & 8) { permissions.push('Administrator'); serverAcknowledgements.push('Server Admin'); } if (bit & 8) { permissions.push('Administrator'); serverAcknowledgements.push('Server Admin'); }
if (bit & 32) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); } if (bit & 32) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); }
if (bit & 16) permissions.push('Manage Channels'); if (bit & 16) permissions.push('Manage Channels');
if (bit & 268435456) permissions.push('Manage Roles'); if (bit & 268435456) permissions.push('Manage Roles');
if (bit & 8192) { permissions.push('Manage Messages'); serverAcknowledgements.push('Server Moderator'); } if (bit & 8192) { permissions.push('Manage Messages'); serverAcknowledgements.push('Server Moderator'); }
if (bit & 134217728) permissions.push('Manage Nicknames'); if (bit & 134217728) permissions.push('Manage Nicknames');
if (bit & 1073741824) permissions.push('Manage Emojis'); if (bit & 1073741824) permissions.push('Manage Emojis');
if (bit & 4) permissions.push('Ban Members'); if (bit & 4) permissions.push('Ban Members');
if (bit & 2) permissions.push('Kick Members'); if (bit & 2) permissions.push('Kick Members');
const account = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec(); const account = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec();
if (account?.additional?.langs?.length > 0) { if (account?.additional?.langs?.length > 0) {
const langs: string[] = []; const langs: string[] = [];
for (const lang of account.additional.langs.sort((a, b) => a.localeCompare(b))) { for (const lang of account.additional.langs.sort((a, b) => a.localeCompare(b))) {
switch (lang) { switch (lang) {
case 'asm': case 'asm':
langs.push('<:AssemblyLanguage:703448714248716442> Assembly Language'); langs.push('<:AssemblyLanguage:703448714248716442> Assembly Language');
break; break;
case 'cfam': case 'cfam':
langs.push('<:clang:553684262193332278> C/C++'); langs.push('<:clang:553684262193332278> C/C++');
break; break;
case 'csharp': case 'csharp':
langs.push('<:csharp:553684277280112660> C#'); langs.push('<:csharp:553684277280112660> C#');
break; break;
case 'go': case 'go':
langs.push('<:Go:703449475405971466> Go'); langs.push('<:Go:703449475405971466> Go');
break; break;
case 'java': case 'java':
langs.push('<:Java:703449725181100135> Java'); langs.push('<:Java:703449725181100135> Java');
break; break;
case 'js': case 'js':
langs.push('<:JavaScriptECMA:703449987916496946> JavaScript'); langs.push('<:JavaScriptECMA:703449987916496946> JavaScript');
break; break;
case 'kt': case 'kt':
langs.push('<:Kotlin:703450201838321684> Kotlin'); langs.push('<:Kotlin:703450201838321684> Kotlin');
break; break;
case 'py': case 'py':
langs.push('<:python:553682965482176513> Python'); langs.push('<:python:553682965482176513> Python');
break; break;
case 'rb': case 'rb':
langs.push('<:ruby:604812470451699712> Ruby'); langs.push('<:ruby:604812470451699712> Ruby');
break; break;
case 'rs': case 'rs':
langs.push('<:Rust:703450901960196206> Rust'); langs.push('<:Rust:703450901960196206> Rust');
break; break;
case 'swift': case 'swift':
langs.push('<:Swift:703451096093294672> Swift'); langs.push('<:Swift:703451096093294672> Swift');
break; break;
case 'ts': case 'ts':
langs.push('<:TypeScript:703451285789343774> TypeScript'); langs.push('<:TypeScript:703451285789343774> TypeScript');
break; break;
default: default:
break; break;
} }
} }
embed.addField('Known Languages', langs.join(', ')); embed.addField('Known Languages', langs.join(', '));
} }
if (account?.additional?.operatingSystems?.length > 0) { if (account?.additional?.operatingSystems?.length > 0) {
const operatingSystems: string[] = []; const operatingSystems: string[] = [];
for (const os of account.additional.operatingSystems.sort((a, b) => a.localeCompare(b))) { for (const os of account.additional.operatingSystems.sort((a, b) => a.localeCompare(b))) {
switch (os) { switch (os) {
case 'arch': case 'arch':
operatingSystems.push('<:arch:707694976523304960> Arch'); operatingSystems.push('<:arch:707694976523304960> Arch');
break; break;
case 'deb': case 'deb':
operatingSystems.push('<:debian:707695042617147589> Debian'); operatingSystems.push('<:debian:707695042617147589> Debian');
break; break;
case 'cent': case 'cent':
operatingSystems.push('<:centos:707702165816213525> CentOS'); operatingSystems.push('<:centos:707702165816213525> CentOS');
break; break;
case 'fedora': case 'fedora':
operatingSystems.push('<:fedora:707695073151680543> Fedora'); operatingSystems.push('<:fedora:707695073151680543> Fedora');
break; break;
case 'manjaro': case 'manjaro':
operatingSystems.push('<:manjaro:707701473680556062> Manjaro'); operatingSystems.push('<:manjaro:707701473680556062> Manjaro');
break; break;
case 'mdarwin': case 'mdarwin':
operatingSystems.push('<:mac:707695427754917919> macOS'); operatingSystems.push('<:mac:707695427754917919> macOS');
break; break;
case 'redhat': case 'redhat':
operatingSystems.push('<:redhat:707695102159749271> RedHat Enterprise Linux'); operatingSystems.push('<:redhat:707695102159749271> RedHat Enterprise Linux');
break; break;
case 'ubuntu': case 'ubuntu':
operatingSystems.push('<:ubuntu:707695136888586300> Ubuntu'); operatingSystems.push('<:ubuntu:707695136888586300> Ubuntu');
break; break;
case 'win': case 'win':
operatingSystems.push('<:windows10:707695160259248208> Windows'); operatingSystems.push('<:windows10:707695160259248208> Windows');
break; break;
default: default:
break; break;
} }
} }
embed.addField('Used Operating Systems', operatingSystems.join(', ')); embed.addField('Used Operating Systems', operatingSystems.join(', '));
} }
if (permissions.length > 0) { if (permissions.length > 0) {
embed.addField('Permissions', permissions.join(', ')); embed.addField('Permissions', permissions.join(', '));
} }
if (account?.x509 || account?.pgp) { if (account?.x509 || account?.pgp) {
if (account.x509 && account.pgp) { if (account.x509 && account.pgp) {
embed.addField('Credentials', `[PGP](https://comm.libraryofcode.org/keys/~/pgp/${member.id}) | [x509](https://comm.libraryofcode.org/keys/~/x509/${member.id})`); embed.addField('Credentials', `[PGP](https://comm.libraryofcode.org/keys/~/pgp/${member.id}) | [x509](https://comm.libraryofcode.org/keys/~/x509/${member.id})`);
} else if (account.pgp) { } else if (account.pgp) {
embed.addField('Credentials', `[PGP](https://comm.libraryofcode.org/keys/~/pgp/${member.id})`); embed.addField('Credentials', `[PGP](https://comm.libraryofcode.org/keys/~/pgp/${member.id})`);
} else if (account.x509) { } else if (account.x509) {
embed.addField('Credentials', `[x509](https://comm.libraryofcode.org/keys/~/x509/${member.id})`); embed.addField('Credentials', `[x509](https://comm.libraryofcode.org/keys/~/x509/${member.id})`);
} }
} }
if (serverAcknowledgements.length > 0) { if (serverAcknowledgements.length > 0) {
embed.addField('Acknowledgements', serverAcknowledgements[0]); embed.addField('Acknowledgements', serverAcknowledgements[0]);
} }
if (ackResolve?.additionalRoles?.length > 0) { if (ackResolve?.additionalRoles?.length > 0) {
embed.addField('Additional Acknowledgements', ackResolve.additionalRoles.join(', ')); embed.addField('Additional Acknowledgements', ackResolve.additionalRoles.join(', '));
} }
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
return ctx.uniCreateMessage({ embed }); return ctx.uniCreateMessage({ embed });
} }
} }