add additional data to report

pull/29/head
Matthew 2020-10-21 03:22:54 -04:00
parent 4b3dea0fc8
commit 358bf2c9c2
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
2 changed files with 86 additions and 1 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable no-bitwise */
/* eslint-disable no-continue */ /* eslint-disable no-continue */
import { TextChannel } from 'eris'; import { TextChannel } from 'eris';
import { Route, Server, RichEmbed } from '../../../class'; import { Route, Server, RichEmbed } from '../../../class';
@ -30,9 +31,29 @@ export default class Report extends Route {
const member = await this.server.client.db.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec(); const member = await this.server.client.db.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
if (!member) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); if (!member) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
const mem = this.server.client.util.resolveMember(member.userID, this.server.client.guilds.get(this.server.client.config.guildID));
if (!mem) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.codes.NOT_FOUND });
if (member.locked) return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED }); if (member.locked) return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED });
if (merchant.type !== 1) return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED }); if (merchant.type !== 1) return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED });
const flags = [];
if (mem.user.publicFlags) {
if ((mem.user.publicFlags & (1 << 0)) === 1 << 0) flags.push('DISCORD_EMPLOYEE');
if ((mem.user.publicFlags & (1 << 1)) === 1 << 1) flags.push('PARTNERED_SERVER_OWNER');
if ((mem.user.publicFlags & (1 << 2)) === 1 << 2) flags.push('HYPESQUAD_EVENTS');
if ((mem.user.publicFlags & (1 << 3)) === 1 << 3) flags.push('BUG_HUNTER_1');
if ((mem.user.publicFlags & (1 << 6)) === 1 << 6) flags.push('HOUSE_BRAVERY');
if ((mem.user.publicFlags & (1 << 7)) === 1 << 7) flags.push('HOUSE_BRILLIANCE');
if ((mem.user.publicFlags & (1 << 8)) === 1 << 8) flags.push('HOUSE_BALANCE');
if ((mem.user.publicFlags & (1 << 9)) === 1 << 9) flags.push('EARLY_SUPPORTER');
if ((mem.user.publicFlags & (1 << 10)) === 1 << 10) flags.push('TEAM_USER');
if ((mem.user.publicFlags & (1 << 12)) === 1 << 12) flags.push('SYSTEM');
if ((mem.user.publicFlags & (1 << 14)) === 1 << 14) flags.push('BUG_HUNTER_2');
if ((mem.user.publicFlags & (1 << 16)) === 1 << 16) flags.push('VERIFIED_BOT');
if ((mem.user.publicFlags & (1 << 17)) === 1 << 17) flags.push('EARLY_VERIFIED_BOT_DEVELOPER');
}
const set = []; const set = [];
const accounts = await this.server.client.db.Score.find().lean().exec(); const accounts = await this.server.client.db.Score.find().lean().exec();
for (const sc of accounts) { for (const sc of accounts) {
@ -90,7 +111,6 @@ export default class Report extends Route {
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Inquiry Notification'); embed.setTitle('Inquiry Notification');
embed.setColor('#800080'); embed.setColor('#800080');
const mem = this.server.client.util.resolveMember(member.userID, this.server.client.guilds.get(this.server.client.config.guildID));
embed.addField('Member', `${mem.user.username}#${mem.user.discriminator} | <@${member.userID}>`, true); embed.addField('Member', `${mem.user.username}#${mem.user.discriminator} | <@${member.userID}>`, true);
embed.addField('Type', 'HARD', true); embed.addField('Type', 'HARD', true);
embed.addField('Department/Service', merchant.name.toUpperCase(), true); embed.addField('Department/Service', merchant.name.toUpperCase(), true);
@ -104,6 +124,15 @@ export default class Report extends Route {
code: this.constants.codes.SUCCESS, code: this.constants.codes.SUCCESS,
message: { message: {
userID: member.userID, userID: member.userID,
memberInformation: {
username: mem.user.username,
discriminator: mem.user.discriminator,
joinedServerAt: new Date(mem.joinedAt),
createdAt: new Date(mem.createdAt),
avatarURL: mem.avatarURL,
flags,
nitroBoost: mem.premiumSince === null,
},
percentile: Math.round(this.server.client.util.percentile(set, member.total)), percentile: Math.round(this.server.client.util.percentile(set, member.total)),
totalScore, totalScore,
activityScore, activityScore,
@ -143,6 +172,7 @@ export default class Report extends Route {
embed.setTitle('Inquiry Notification'); embed.setTitle('Inquiry Notification');
embed.setColor('#00FFFF'); embed.setColor('#00FFFF');
const mem = this.server.client.util.resolveMember(member.userID, this.server.client.guilds.get(this.server.client.config.guildID)); const mem = this.server.client.util.resolveMember(member.userID, this.server.client.guilds.get(this.server.client.config.guildID));
if (!mem) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.codes.NOT_FOUND });
embed.addField('Member', `${mem.user.username}#${mem.user.discriminator} | <@${member.userID}>`, true); embed.addField('Member', `${mem.user.username}#${mem.user.discriminator} | <@${member.userID}>`, true);
embed.addField('Type', 'SOFT', true); embed.addField('Type', 'SOFT', true);
embed.addField('Department/Service', merchant.name.toUpperCase(), true); embed.addField('Department/Service', merchant.name.toUpperCase(), true);
@ -160,6 +190,30 @@ export default class Report extends Route {
}, },
}); });
} }
const flags = [];
if (mem.user.publicFlags) {
if ((mem.user.publicFlags & (1 << 0)) === 1 << 0) flags.push('DISCORD_EMPLOYEE');
if ((mem.user.publicFlags & (1 << 1)) === 1 << 1) flags.push('PARTNERED_SERVER_OWNER');
if ((mem.user.publicFlags & (1 << 2)) === 1 << 2) flags.push('HYPESQUAD_EVENTS');
if ((mem.user.publicFlags & (1 << 3)) === 1 << 3) flags.push('BUG_HUNTER_1');
if ((mem.user.publicFlags & (1 << 6)) === 1 << 6) flags.push('HOUSE_BRAVERY');
if ((mem.user.publicFlags & (1 << 7)) === 1 << 7) flags.push('HOUSE_BRILLIANCE');
if ((mem.user.publicFlags & (1 << 8)) === 1 << 8) flags.push('HOUSE_BALANCE');
if ((mem.user.publicFlags & (1 << 9)) === 1 << 9) flags.push('EARLY_SUPPORTER');
if ((mem.user.publicFlags & (1 << 10)) === 1 << 10) flags.push('TEAM_USER');
if ((mem.user.publicFlags & (1 << 12)) === 1 << 12) flags.push('SYSTEM');
if ((mem.user.publicFlags & (1 << 14)) === 1 << 14) flags.push('BUG_HUNTER_2');
if ((mem.user.publicFlags & (1 << 16)) === 1 << 16) flags.push('VERIFIED_BOT');
if ((mem.user.publicFlags & (1 << 17)) === 1 << 17) flags.push('EARLY_VERIFIED_BOT_DEVELOPER');
}
const set = [];
const accounts = await this.server.client.db.Score.find().lean().exec();
for (const sc of accounts) {
if (sc.total < 200) { continue; }
if (sc.total > 800) { set.push(800); continue; }
set.push(sc.total);
}
let activityScore: number; let activityScore: number;
const moderationScore = Math.round(member.moderation); const moderationScore = Math.round(member.moderation);
let roleScore: number; let roleScore: number;
@ -187,7 +241,17 @@ export default class Report extends Route {
code: this.constants.codes.SUCCESS, code: this.constants.codes.SUCCESS,
message: { message: {
userID: member.userID, userID: member.userID,
memberInformation: {
username: mem.user.username,
discriminator: mem.user.discriminator,
joinedServerAt: new Date(mem.joinedAt),
createdAt: new Date(mem.createdAt),
avatarURL: mem.avatarURL,
flags,
nitroBoost: mem.premiumSince === null,
},
totalScore, totalScore,
percentile: Math.round(this.server.client.util.percentile(set, member.total)),
activityScore, activityScore,
moderationScore, moderationScore,
roleScore, roleScore,

View File

@ -34,7 +34,26 @@ export default class Whois extends Command {
let title = `${member.user.username}#${member.user.discriminator}`; let title = `${member.user.username}#${member.user.discriminator}`;
if (ackResolve?.pn?.length > 0) title += `, ${ackResolve.pn.join(', ')}`; if (ackResolve?.pn?.length > 0) title += `, ${ackResolve.pn.join(', ')}`;
embed.setAuthor(title, member.user.avatarURL); embed.setAuthor(title, member.user.avatarURL);
const flags = [];
if (member.user.publicFlags) {
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) flags.push('<:loc:607695848612167700>');
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 << 1)) === 1 << 1) flags.push('<:Partnered:768370601395879936>');
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 << 2)) === 1 << 2) flags.push('<:HypeSquadEvents:768370600745762846>');
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 << 8)) === 1 << 8) flags.push('<:HypeSquadBalance:768370599584071751> ');
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 << 17)) === 1 << 17) flags.push('<:VerifiedBotDeveloper:768370601701933077>');
}
let description = ''; let description = '';
if (flags.length > 0) description += `${flags.join(' ')}\n\n`;
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`;
@ -96,6 +115,8 @@ export default class Whois extends Command {
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.Member.findOne({ userID: member.id }).lean().exec(); const account = await this.client.db.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[] = [];