forked from engineering/cloudservices
fixes and whatnot or whatever
parent
ae272d7aee
commit
2880dc4eb7
|
@ -150,6 +150,36 @@ export default class Webhook extends Route {
|
|||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
this.router.get('/set-tier', 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 });
|
||||
|
||||
if (Number(req.query.t.toString()) > 3 || Number(req.query.t.toString()) < 1) 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() });
|
||||
if (!account) return res.sendStatus(404);
|
||||
const tier = await this.server.client.db.Tier.findOne({ id: Number(req.query.t.toString()) });
|
||||
|
||||
if (account.ramLimitNotification !== -1) {
|
||||
await account.updateOne({ $set: { tier: Number(req.query.t.toString()), ramLimitNotification: tier.resourceLimits.ram - 20 } });
|
||||
} else {
|
||||
await account.updateOne({ $set: { tier: Number(req.query.t.toString()) } });
|
||||
}
|
||||
const embed = new MessageEmbed();
|
||||
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} -> 1`, 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.').catch(() => { });
|
||||
const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel;
|
||||
ch.send({ embeds: [embed] });
|
||||
this.server.client.users.cache.get(account.userID).send({ embeds: [embed] });
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
this.router.get('/info', async (req, res) => {
|
||||
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 });
|
||||
if (!req.query?.id) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
|
Loading…
Reference in New Issue