Update with UUIDs
parent
e084efc369
commit
64b59bdd35
|
@ -1,4 +1,5 @@
|
||||||
import { TextChannel } from 'eris';
|
import { TextChannel } from 'eris';
|
||||||
|
import { v4 as genUUID } from 'uuid';
|
||||||
import { RichEmbed, Route, Server } from '../../../class';
|
import { RichEmbed, Route, Server } from '../../../class';
|
||||||
|
|
||||||
export default class Root extends Route {
|
export default class Root extends Route {
|
||||||
|
@ -28,14 +29,14 @@ export default class Root extends Route {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req.body.subject) {
|
if (!req.body.subject) {
|
||||||
return res.status(401).json({
|
return res.status(400).json({
|
||||||
code: this.constants.codes.CLIENT_ERROR,
|
code: this.constants.codes.CLIENT_ERROR,
|
||||||
message: this.constants.messages.CLIENT_ERROR,
|
message: this.constants.messages.CLIENT_ERROR,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req.body.body) {
|
if (!req.body.body) {
|
||||||
return res.status(401).json({
|
return res.status(400).json({
|
||||||
code: this.constants.codes.CLIENT_ERROR,
|
code: this.constants.codes.CLIENT_ERROR,
|
||||||
message: this.constants.messages.CLIENT_ERROR,
|
message: this.constants.messages.CLIENT_ERROR,
|
||||||
});
|
});
|
||||||
|
@ -46,6 +47,7 @@ export default class Root extends Route {
|
||||||
subject: req.body.subject,
|
subject: req.body.subject,
|
||||||
body: req.body.body,
|
body: req.body.body,
|
||||||
at: new Date(),
|
at: new Date(),
|
||||||
|
oID: genUUID(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const staffInformation = await this.server.client.db.Staff.findOne({ userID: director.userID });
|
const staffInformation = await this.server.client.db.Staff.findOne({ userID: director.userID });
|
||||||
|
@ -57,7 +59,7 @@ export default class Root extends Route {
|
||||||
embed.setColor('#dd3acd');
|
embed.setColor('#dd3acd');
|
||||||
embed.addField('Subject', req.body.subject);
|
embed.addField('Subject', req.body.subject);
|
||||||
embed.addField('Body', req.body.body);
|
embed.addField('Body', req.body.body);
|
||||||
embed.addField('ID', executiveOrder._id);
|
embed.addField('ID', executiveOrder.oID);
|
||||||
embed.setTimestamp(new Date());
|
embed.setTimestamp(new Date());
|
||||||
|
|
||||||
const channel = <TextChannel>this.server.client.getChannel('807444198969835550');
|
const channel = <TextChannel>this.server.client.getChannel('807444198969835550');
|
||||||
|
@ -65,7 +67,7 @@ export default class Root extends Route {
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: this.constants.codes.SUCCESS,
|
code: this.constants.codes.SUCCESS,
|
||||||
message: `Created new Executive Order with ID ${executiveOrder._id} by the ${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}.`,
|
message: `Created new Executive Order with ID ${executiveOrder.oID} by the ${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}.`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import locsh from './loc.sh/main';
|
import locsh from './loc.sh/main';
|
||||||
import crins from './cr.ins/main';
|
import crins from './cr.ins/main';
|
||||||
import commlibraryofcodeorg from './comm.libraryofcode.org/main';
|
import commlibraryofcodeorg from './comm.libraryofcode.org/main';
|
||||||
|
import boardins from './board.ins/main';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
'board.ins': boardins,
|
||||||
'loc.sh': locsh,
|
'loc.sh': locsh,
|
||||||
'cr.ins': crins,
|
'cr.ins': crins,
|
||||||
'comm.libraryofcode.org': commlibraryofcodeorg,
|
'comm.libraryofcode.org': commlibraryofcodeorg,
|
||||||
|
|
|
@ -5,6 +5,7 @@ export interface ExecutiveOrderInterface extends Document {
|
||||||
subject: string;
|
subject: string;
|
||||||
body: string;
|
body: string;
|
||||||
at: Date;
|
at: Date;
|
||||||
|
oID: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExecutiveOrder = new Schema({
|
const ExecutiveOrder = new Schema({
|
||||||
|
@ -12,6 +13,7 @@ const ExecutiveOrder = new Schema({
|
||||||
subject: { type: String, required: true },
|
subject: { type: String, required: true },
|
||||||
body: { type: String, required: true },
|
body: { type: String, required: true },
|
||||||
at: { type: Date, required: true },
|
at: { type: Date, required: true },
|
||||||
|
oID: { type: String, required: true, unique: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model<ExecutiveOrderInterface>('ExecutiveOrders', ExecutiveOrder);
|
export default model<ExecutiveOrderInterface>('ExecutiveOrders', ExecutiveOrder);
|
||||||
|
|
Loading…
Reference in New Issue