From c251ccffa17900f85a186136260301342cdf7539 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 15 Aug 2020 01:42:19 -0400 Subject: [PATCH] staff directory --- src/api/loc.sh/routes/index.ts | 1 + src/api/loc.sh/routes/internal.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/api/loc.sh/routes/internal.ts diff --git a/src/api/loc.sh/routes/index.ts b/src/api/loc.sh/routes/index.ts index baf2256..4d199cc 100644 --- a/src/api/loc.sh/routes/index.ts +++ b/src/api/loc.sh/routes/index.ts @@ -1 +1,2 @@ export { default as root } from './root'; +export { default as internal } from './internal'; diff --git a/src/api/loc.sh/routes/internal.ts b/src/api/loc.sh/routes/internal.ts new file mode 100644 index 0000000..090a02e --- /dev/null +++ b/src/api/loc.sh/routes/internal.ts @@ -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); + } + }); + } +}