Executive Orders
parent
38f5a5f70e
commit
e084efc369
|
@ -0,0 +1,3 @@
|
|||
import { Server, ServerManagement } from '../../class';
|
||||
|
||||
export default (management: ServerManagement) => new Server(management, 3892, `${__dirname}/routes`);
|
|
@ -0,0 +1 @@
|
|||
export { default as Root } from './root';
|
|
@ -0,0 +1,72 @@
|
|||
import { TextChannel } from 'eris';
|
||||
import { RichEmbed, Route, Server } from '../../../class';
|
||||
|
||||
export default class Root extends Route {
|
||||
constructor(server: Server) {
|
||||
super(server);
|
||||
this.conf = {
|
||||
path: '/',
|
||||
};
|
||||
}
|
||||
|
||||
public bind() {
|
||||
this.router.post('/executive-orders/new', async (req, res) => {
|
||||
if (!req.body.pin) {
|
||||
return res.status(401).json({
|
||||
code: this.constants.codes.UNAUTHORIZED,
|
||||
message: this.constants.messages.UNAUTHORIZED,
|
||||
});
|
||||
}
|
||||
|
||||
const director = await this.server.client.db.Score.findOne({ pin: req.body.pin });
|
||||
|
||||
if (!director) {
|
||||
return res.status(401).json({
|
||||
code: this.constants.codes.UNAUTHORIZED,
|
||||
message: this.constants.messages.UNAUTHORIZED,
|
||||
});
|
||||
}
|
||||
|
||||
if (!req.body.subject) {
|
||||
return res.status(401).json({
|
||||
code: this.constants.codes.CLIENT_ERROR,
|
||||
message: this.constants.messages.CLIENT_ERROR,
|
||||
});
|
||||
}
|
||||
|
||||
if (!req.body.body) {
|
||||
return res.status(401).json({
|
||||
code: this.constants.codes.CLIENT_ERROR,
|
||||
message: this.constants.messages.CLIENT_ERROR,
|
||||
});
|
||||
}
|
||||
|
||||
const executiveOrder = await this.server.client.db.ExecutiveOrder.create({
|
||||
issuedBy: director.userID,
|
||||
subject: req.body.subject,
|
||||
body: req.body.body,
|
||||
at: new Date(),
|
||||
});
|
||||
|
||||
const staffInformation = await this.server.client.db.Staff.findOne({ userID: director.userID });
|
||||
const staffDiscord = this.server.client.users.get(director.userID) || await this.server.client.getRESTUser(director.userID);
|
||||
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Executive Order');
|
||||
embed.setAuthor(`${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}`, staffDiscord.avatarURL);
|
||||
embed.setColor('#dd3acd');
|
||||
embed.addField('Subject', req.body.subject);
|
||||
embed.addField('Body', req.body.body);
|
||||
embed.addField('ID', executiveOrder._id);
|
||||
embed.setTimestamp(new Date());
|
||||
|
||||
const channel = <TextChannel>this.server.client.getChannel('807444198969835550');
|
||||
await channel.createMessage({ embed });
|
||||
|
||||
return res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
message: `Created new Executive Order with ID ${executiveOrder._id} by the ${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}.`,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -77,7 +77,6 @@ export default class Report extends Route {
|
|||
return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED });
|
||||
}
|
||||
|
||||
|
||||
const flags = [];
|
||||
if (mem.user.publicFlags) {
|
||||
if ((mem.user.publicFlags & (1 << 0)) === 1 << 0) flags.push('DISCORD_EMPLOYEE');
|
||||
|
@ -196,8 +195,8 @@ export default class Report extends Route {
|
|||
embed.addField('Reason', req.body.reason ?? 'N/A', true);
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => {});
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => { });
|
||||
|
||||
return res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -259,8 +258,8 @@ export default class Report extends Route {
|
|||
embed.addField('Department/Service', merchant.name.toUpperCase(), true);
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => {});
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => { });
|
||||
|
||||
if (!merchant.privileged) {
|
||||
return res.status(200).json({
|
||||
|
@ -355,7 +354,6 @@ export default class Report extends Route {
|
|||
array.push(data);
|
||||
}
|
||||
|
||||
|
||||
return res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
message: {
|
||||
|
@ -414,8 +412,8 @@ export default class Report extends Route {
|
|||
embed.addField('Department/Service', merchant.name.toUpperCase(), true);
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => {});
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => { });
|
||||
|
||||
if (!merchant.privileged) {
|
||||
return res.status(200).json({
|
||||
|
@ -448,7 +446,6 @@ export default class Report extends Route {
|
|||
else if (member.cloudServices > 10) cloudServicesScore = 10;
|
||||
else cloudServicesScore = Math.round(member.cloudServices);
|
||||
|
||||
|
||||
return res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
message: {
|
||||
|
@ -498,8 +495,8 @@ export default class Report extends Route {
|
|||
embed.addField('Department/Service', `${member.username} via report.libraryofcode.org @ IP ${req.ip}`.toUpperCase(), true);
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => {});
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => { });
|
||||
} else {
|
||||
await this.server.client.db.Score.updateOne({ userID: score.userID }, { $addToSet: { softInquiries: { name: 'Library of Code sp-us | Staff Team via report.libraryofcode.org', date: new Date() } } });
|
||||
const embed = new RichEmbed();
|
||||
|
@ -510,8 +507,8 @@ export default class Report extends Route {
|
|||
embed.addField('Department/Service', 'Library of Code sp-us | Staff Team via report.libraryofcode.org'.toUpperCase(), true);
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => {});
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => { });
|
||||
}
|
||||
} else if (!updated) {
|
||||
await this.server.client.db.Score.updateOne({ userID: score.userID }, { $addToSet: { softInquiries: { name: `${member.username} via report.libraryofcode.org @ IP ${req.ip}`, date: new Date() } } });
|
||||
|
@ -523,8 +520,8 @@ export default class Report extends Route {
|
|||
embed.addField('Department/Service', `${member.username} via report.libraryofcode.org @ IP ${req.ip}`.toUpperCase(), true);
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => {});
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||
chan.createMessage({ embed }).catch(() => { });
|
||||
}
|
||||
score = await this.server.client.db.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
|
||||
|
@ -646,11 +643,11 @@ export default class Report extends Route {
|
|||
name?: string,
|
||||
department?: string,
|
||||
date?: Date,
|
||||
}> jwt.verify(req.query.code.toString(), this.server.client.config.internalKey);
|
||||
}>jwt.verify(req.query.code.toString(), this.server.client.config.internalKey);
|
||||
} catch {
|
||||
return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
}
|
||||
const chan = <TextChannel> this.server.client.guilds.get(this.constants.discord.SERVER_ID).channels.get(offer.channelID);
|
||||
const chan = <TextChannel>this.server.client.guilds.get(this.constants.discord.SERVER_ID).channels.get(offer.channelID);
|
||||
await chan.createMessage(`__**PRE-APPROVED OFFER ACCEPTED**__\n<@${offer.staffID}>`);
|
||||
const message = await chan.getMessage(offer.messageID);
|
||||
const args = [];
|
||||
|
|
|
@ -7,6 +7,7 @@ import { Collection, Command, LocalStorage, Queue, Util, ServerManagement, Event
|
|||
import {
|
||||
Customer, CustomerInterface,
|
||||
CustomerPortal, CustomerPortalInterface,
|
||||
ExecutiveOrder, ExecutiveOrderInterface,
|
||||
File, FileInterface,
|
||||
Member, MemberInterface,
|
||||
Merchant, MerchantInterface,
|
||||
|
@ -43,7 +44,7 @@ export default class Client extends eris.Client {
|
|||
|
||||
public stripe: Stripe;
|
||||
|
||||
public db: { Customer: mongoose.Model<CustomerInterface>, CustomerPortal: mongoose.Model<CustomerPortalInterface>, File: mongoose.Model<FileInterface>, Member: mongoose.Model<MemberInterface>, Merchant: mongoose.Model<MerchantInterface>, Moderation: mongoose.Model<ModerationInterface>, NNTrainingData: mongoose.Model<NNTrainingDataInterface>, Note: mongoose.Model<NoteInterface>, PagerNumber: mongoose.Model<PagerNumberInterface>, Promo: mongoose.Model<PromoInterface>, Rank: mongoose.Model<RankInterface>, Redirect: mongoose.Model<RedirectInterface>, Score: mongoose.Model<ScoreInterface>, ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>, Staff: mongoose.Model<StaffInterface>, Stat: mongoose.Model<StatInterface>, local: { muted: LocalStorage } };
|
||||
public db: { Customer: mongoose.Model<CustomerInterface>, CustomerPortal: mongoose.Model<CustomerPortalInterface>, ExecutiveOrder: mongoose.Model<ExecutiveOrderInterface>, File: mongoose.Model<FileInterface>, Member: mongoose.Model<MemberInterface>, Merchant: mongoose.Model<MerchantInterface>, Moderation: mongoose.Model<ModerationInterface>, NNTrainingData: mongoose.Model<NNTrainingDataInterface>, Note: mongoose.Model<NoteInterface>, PagerNumber: mongoose.Model<PagerNumberInterface>, Promo: mongoose.Model<PromoInterface>, Rank: mongoose.Model<RankInterface>, Redirect: mongoose.Model<RedirectInterface>, Score: mongoose.Model<ScoreInterface>, ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>, Staff: mongoose.Model<StaffInterface>, Stat: mongoose.Model<StatInterface>, local: { muted: LocalStorage } };
|
||||
|
||||
constructor(token: string, options?: eris.ClientOptions) {
|
||||
super(token, options);
|
||||
|
@ -51,7 +52,7 @@ export default class Client extends eris.Client {
|
|||
this.events = new Collection<Event>();
|
||||
this.intervals = new Collection<NodeJS.Timeout>();
|
||||
this.queue = new Queue(this);
|
||||
this.db = { Customer, CustomerPortal, File, Member, Merchant, Moderation, NNTrainingData, Note, PagerNumber, Promo, Rank, Redirect, Score, ScoreHistorical, Staff, Stat, local: { muted: new LocalStorage('muted') } };
|
||||
this.db = { Customer, CustomerPortal, ExecutiveOrder, File, Member, Merchant, Moderation, NNTrainingData, Note, PagerNumber, Promo, Rank, Redirect, Score, ScoreHistorical, Staff, Stat, local: { muted: new LocalStorage('muted') } };
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class GuildMemberAdd extends Event {
|
|||
public async run(_, member: Member) {
|
||||
try {
|
||||
const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`);
|
||||
if (search === true) {
|
||||
if (search) {
|
||||
member.addRole('478373942638149643');
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import { Document, model, Schema } from 'mongoose';
|
||||
|
||||
export interface ExecutiveOrderInterface extends Document {
|
||||
issuedBy: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
at: Date;
|
||||
}
|
||||
|
||||
const ExecutiveOrder = new Schema({
|
||||
issuedBy: { type: String, required: true },
|
||||
subject: { type: String, required: true },
|
||||
body: { type: String, required: true },
|
||||
at: { type: Date, required: true },
|
||||
});
|
||||
|
||||
export default model<ExecutiveOrderInterface>('ExecutiveOrders', ExecutiveOrder);
|
|
@ -1,5 +1,6 @@
|
|||
export { default as Customer, CustomerInterface } from './Customer';
|
||||
export { default as CustomerPortal, CustomerPortalInterface } from './CustomerPortal';
|
||||
export { default as ExecutiveOrder, ExecutiveOrderInterface } from './ExecutiveOrder';
|
||||
export { default as File, FileInterface } from './File';
|
||||
export { default as Member, MemberInterface } from './Member';
|
||||
export { default as Merchant, MerchantInterface } from './Merchant';
|
||||
|
|
Loading…
Reference in New Issue