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 });
|
return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const flags = [];
|
const flags = [];
|
||||||
if (mem.user.publicFlags) {
|
if (mem.user.publicFlags) {
|
||||||
if ((mem.user.publicFlags & (1 << 0)) === 1 << 0) flags.push('DISCORD_EMPLOYEE');
|
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.addField('Reason', req.body.reason ?? 'N/A', true);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
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');
|
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||||
chan.createMessage({ embed }).catch(() => {});
|
chan.createMessage({ embed }).catch(() => { });
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: this.constants.codes.SUCCESS,
|
code: this.constants.codes.SUCCESS,
|
||||||
|
@ -259,8 +258,8 @@ export default class Report extends Route {
|
||||||
embed.addField('Department/Service', merchant.name.toUpperCase(), true);
|
embed.addField('Department/Service', merchant.name.toUpperCase(), true);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
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');
|
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||||
chan.createMessage({ embed }).catch(() => {});
|
chan.createMessage({ embed }).catch(() => { });
|
||||||
|
|
||||||
if (!merchant.privileged) {
|
if (!merchant.privileged) {
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
|
@ -355,7 +354,6 @@ export default class Report extends Route {
|
||||||
array.push(data);
|
array.push(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: this.constants.codes.SUCCESS,
|
code: this.constants.codes.SUCCESS,
|
||||||
message: {
|
message: {
|
||||||
|
@ -414,8 +412,8 @@ export default class Report extends Route {
|
||||||
embed.addField('Department/Service', merchant.name.toUpperCase(), true);
|
embed.addField('Department/Service', merchant.name.toUpperCase(), true);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
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');
|
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||||
chan.createMessage({ embed }).catch(() => {});
|
chan.createMessage({ embed }).catch(() => { });
|
||||||
|
|
||||||
if (!merchant.privileged) {
|
if (!merchant.privileged) {
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
|
@ -448,7 +446,6 @@ export default class Report extends Route {
|
||||||
else if (member.cloudServices > 10) cloudServicesScore = 10;
|
else if (member.cloudServices > 10) cloudServicesScore = 10;
|
||||||
else cloudServicesScore = Math.round(member.cloudServices);
|
else cloudServicesScore = Math.round(member.cloudServices);
|
||||||
|
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: this.constants.codes.SUCCESS,
|
code: this.constants.codes.SUCCESS,
|
||||||
message: {
|
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.addField('Department/Service', `${member.username} via report.libraryofcode.org @ IP ${req.ip}`.toUpperCase(), true);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
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');
|
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||||
chan.createMessage({ embed }).catch(() => {});
|
chan.createMessage({ embed }).catch(() => { });
|
||||||
} else {
|
} 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() } } });
|
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();
|
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.addField('Department/Service', 'Library of Code sp-us | Staff Team via report.libraryofcode.org'.toUpperCase(), true);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
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');
|
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||||
chan.createMessage({ embed }).catch(() => {});
|
chan.createMessage({ embed }).catch(() => { });
|
||||||
}
|
}
|
||||||
} else if (!updated) {
|
} 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() } } });
|
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.addField('Department/Service', `${member.username} via report.libraryofcode.org @ IP ${req.ip}`.toUpperCase(), true);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL);
|
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');
|
const chan = <TextChannel>this.server.client.guilds.get(this.server.client.config.guildID).channels.get('611584771356622849');
|
||||||
chan.createMessage({ embed }).catch(() => {});
|
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();
|
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,
|
name?: string,
|
||||||
department?: string,
|
department?: string,
|
||||||
date?: Date,
|
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 {
|
} catch {
|
||||||
return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
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}>`);
|
await chan.createMessage(`__**PRE-APPROVED OFFER ACCEPTED**__\n<@${offer.staffID}>`);
|
||||||
const message = await chan.getMessage(offer.messageID);
|
const message = await chan.getMessage(offer.messageID);
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Collection, Command, LocalStorage, Queue, Util, ServerManagement, Event
|
||||||
import {
|
import {
|
||||||
Customer, CustomerInterface,
|
Customer, CustomerInterface,
|
||||||
CustomerPortal, CustomerPortalInterface,
|
CustomerPortal, CustomerPortalInterface,
|
||||||
|
ExecutiveOrder, ExecutiveOrderInterface,
|
||||||
File, FileInterface,
|
File, FileInterface,
|
||||||
Member, MemberInterface,
|
Member, MemberInterface,
|
||||||
Merchant, MerchantInterface,
|
Merchant, MerchantInterface,
|
||||||
|
@ -43,7 +44,7 @@ export default class Client extends eris.Client {
|
||||||
|
|
||||||
public stripe: Stripe;
|
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) {
|
constructor(token: string, options?: eris.ClientOptions) {
|
||||||
super(token, options);
|
super(token, options);
|
||||||
|
@ -51,7 +52,7 @@ export default class Client extends eris.Client {
|
||||||
this.events = new Collection<Event>();
|
this.events = new Collection<Event>();
|
||||||
this.intervals = new Collection<NodeJS.Timeout>();
|
this.intervals = new Collection<NodeJS.Timeout>();
|
||||||
this.queue = new Queue(this);
|
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) {
|
public async run(_, member: Member) {
|
||||||
try {
|
try {
|
||||||
const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`);
|
const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`);
|
||||||
if (search === true) {
|
if (search) {
|
||||||
member.addRole('478373942638149643');
|
member.addRole('478373942638149643');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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 Customer, CustomerInterface } from './Customer';
|
||||||
export { default as CustomerPortal, CustomerPortalInterface } from './CustomerPortal';
|
export { default as CustomerPortal, CustomerPortalInterface } from './CustomerPortal';
|
||||||
|
export { default as ExecutiveOrder, ExecutiveOrderInterface } from './ExecutiveOrder';
|
||||||
export { default as File, FileInterface } from './File';
|
export { default as File, FileInterface } from './File';
|
||||||
export { default as Member, MemberInterface } from './Member';
|
export { default as Member, MemberInterface } from './Member';
|
||||||
export { default as Merchant, MerchantInterface } from './Merchant';
|
export { default as Merchant, MerchantInterface } from './Merchant';
|
||||||
|
|
Loading…
Reference in New Issue