staff directory

merge-requests/15/head
Matthew 2020-08-15 01:42:19 -04:00
parent 227a57850a
commit c251ccffa1
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
2 changed files with 30 additions and 0 deletions

View File

@ -1 +1,2 @@
export { default as root } from './root'; export { default as root } from './root';
export { default as internal } from './internal';

View File

@ -0,0 +1,29 @@
import { Route, Server } from '../../../class';
import acknowledgements from '../../../configs/acknowledgements.json';
export default class Internal extends Route {
constructor(server: Server) {
super(server);
this.conf = {
path: '/int',
};
}
public bind() {
this.router.get('/directory', async (req, res) => {
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 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 });
}
return res.status(200).json(acknowledgements);
} catch (err) {
return this.handleError(err, res);
}
});
}
}