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');
|
||||||
|
@ -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: {
|
||||||
|
@ -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: {
|
||||||
|
|
|
@ -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