performance fixes

merge-requests/15/head
Matthew 2020-08-15 22:53:41 -04:00
parent c251ccffa1
commit 91ce5bb5e8
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 4 additions and 2 deletions

View File

@ -14,8 +14,10 @@ export default class Internal extends Route {
try {
res.setHeader('Access-Control-Allow-Origin', '*');
if (req.query.id) {
const member = await this.server.client.getRESTGuildMember(this.server.client.config.guildID, req.query.id.toString());
const pagerNumber = await this.server.client.db.PagerNumber.findOne({ individualAssignID: member.id });
let member = this.server.client.guilds.get(this.server.client.config.guildID).members.get(req.query.id.toString());
if (!member) member = await this.server.client.getRESTGuildMember(this.server.client.config.guildID, req.query.id.toString());
if (!member) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
const pagerNumber = await this.server.client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
let status = false;
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) status = true;
return res.status(200).json({ staff: status, username: member.user.username, discriminator: member.user.discriminator, nick: member.nick, avatarURL: member.user.avatarURL, pager: pagerNumber?.num });