diff --git a/src/api/comm.libraryofcode.org/routes/report.ts b/src/api/comm.libraryofcode.org/routes/report.ts index ca1b4a8..1ca7e58 100644 --- a/src/api/comm.libraryofcode.org/routes/report.ts +++ b/src/api/comm.libraryofcode.org/routes/report.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-bitwise */ /* eslint-disable no-continue */ import { TextChannel } from 'eris'; 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(); 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 (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 accounts = await this.server.client.db.Score.find().lean().exec(); for (const sc of accounts) { @@ -90,7 +111,6 @@ export default class Report extends Route { const embed = new RichEmbed(); embed.setTitle('Inquiry Notification'); 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('Type', 'HARD', true); embed.addField('Department/Service', merchant.name.toUpperCase(), true); @@ -104,6 +124,15 @@ export default class Report extends Route { code: this.constants.codes.SUCCESS, message: { 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)), totalScore, activityScore, @@ -143,6 +172,7 @@ export default class Report extends Route { embed.setTitle('Inquiry Notification'); embed.setColor('#00FFFF'); 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('Type', 'SOFT', 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; const moderationScore = Math.round(member.moderation); let roleScore: number; @@ -187,7 +241,17 @@ export default class Report extends Route { code: this.constants.codes.SUCCESS, message: { 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, + percentile: Math.round(this.server.client.util.percentile(set, member.total)), activityScore, moderationScore, roleScore, diff --git a/src/commands/whois.ts b/src/commands/whois.ts index d661592..6943132 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -34,7 +34,26 @@ export default class Whois extends Command { let title = `${member.user.username}#${member.user.discriminator}`; if (ackResolve?.pn?.length > 0) title += `, ${ackResolve.pn.join(', ')}`; 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 = ''; + if (flags.length > 0) description += `${flags.join(' ')}\n\n`; let titleAndDepartment = ''; if (ackResolve?.title && ackResolve?.dept) { 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 & 4) permissions.push('Ban Members'); if (bit & 2) permissions.push('Kick Members'); + + const account = await this.client.db.Member.findOne({ userID: member.id }).lean().exec(); if (account?.additional?.langs?.length > 0) { const langs: string[] = [];