From a636cc66d4476f41b7b7b8d3587222d3a37dc706 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 31 Oct 2020 02:26:25 -0400 Subject: [PATCH] api changes --- src/api/routes/Webhook.ts | 23 +++++++++++++++++++++++ src/commands/applyt2.ts | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/api/routes/Webhook.ts b/src/api/routes/Webhook.ts index c5797e4..d30c1ec 100644 --- a/src/api/routes/Webhook.ts +++ b/src/api/routes/Webhook.ts @@ -30,6 +30,29 @@ export default class Webhook extends Route { } }); + this.router.get('/t2', async (req, res) => { + if (req.query?.auth !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); + if (!req.query?.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR }); + + const account = await this.server.client.db.Account.findOne({ userID: req.query.userID.toString() }); + const tier = await this.server.client.db.Tier.findOne({ id: 2 }); + if (account.ramLimitNotification !== -1) { + await account.updateOne({ $set: { tier: 2, ramLimitNotification: tier.resourceLimits.ram - 20 } }); + } else { + await account.updateOne({ $set: { tier: 2 } }); + } + const embed = new RichEmbed(); + embed.setTitle('Cloud Account | Tier Change'); + embed.setColor('#0099ff'); + embed.addField('User', `${account.username} | <@${account.userID}>`, true); + embed.addField('Technician', 'SYSTEM', true); + embed.addField('Old Tier -> New Tier', `${account.tier} -> 2`, true); + embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL); + embed.setTimestamp(); + await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 2').catch(() => { }); + this.server.client.createMessage('580950455581147146', { embed }); return this.server.client.getDMChannel(account.userID).then((channel) => channel.createMessage({ embed })).catch(); + }); + this.router.get('/score', async (req, res) => { try { if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); diff --git a/src/commands/applyt2.ts b/src/commands/applyt2.ts index fb0f907..910b0a3 100644 --- a/src/commands/applyt2.ts +++ b/src/commands/applyt2.ts @@ -7,7 +7,7 @@ export default class ApplyT2 extends Command { super(client); this.name = 'apply-t2'; this.description = 'Applies for Tier 2.'; - this.enabled = true; + this.enabled = false; this.guildOnly = true; this.aliases = ['t2']; this.usage = `${this.client.config.prefix}apply-t2`;