diff --git a/src/api/board.ins/routes/root.ts b/src/api/board.ins/routes/root.ts index e908f7d..8fb4542 100644 --- a/src/api/board.ins/routes/root.ts +++ b/src/api/board.ins/routes/root.ts @@ -1,4 +1,5 @@ import { TextChannel } from 'eris'; +import { v4 as genUUID } from 'uuid'; import { RichEmbed, Route, Server } from '../../../class'; export default class Root extends Route { @@ -28,14 +29,14 @@ export default class Root extends Route { } if (!req.body.subject) { - return res.status(401).json({ + return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR, }); } if (!req.body.body) { - return res.status(401).json({ + return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR, }); @@ -46,6 +47,7 @@ export default class Root extends Route { subject: req.body.subject, body: req.body.body, at: new Date(), + oID: genUUID(), }); 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.addField('Subject', req.body.subject); embed.addField('Body', req.body.body); - embed.addField('ID', executiveOrder._id); + embed.addField('ID', executiveOrder.oID); embed.setTimestamp(new Date()); const channel = this.server.client.getChannel('807444198969835550'); @@ -65,7 +67,7 @@ export default class Root extends Route { 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(', ')}.`, + message: `Created new Executive Order with ID ${executiveOrder.oID} by the ${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}.`, }); }); } diff --git a/src/api/index.ts b/src/api/index.ts index 9af7ae9..096c31c 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,8 +1,10 @@ import locsh from './loc.sh/main'; import crins from './cr.ins/main'; import commlibraryofcodeorg from './comm.libraryofcode.org/main'; +import boardins from './board.ins/main'; export default { + 'board.ins': boardins, 'loc.sh': locsh, 'cr.ins': crins, 'comm.libraryofcode.org': commlibraryofcodeorg, diff --git a/src/models/ExecutiveOrder.ts b/src/models/ExecutiveOrder.ts index a096f84..f639358 100644 --- a/src/models/ExecutiveOrder.ts +++ b/src/models/ExecutiveOrder.ts @@ -5,6 +5,7 @@ export interface ExecutiveOrderInterface extends Document { subject: string; body: string; at: Date; + oID: string; } const ExecutiveOrder = new Schema({ @@ -12,6 +13,7 @@ const ExecutiveOrder = new Schema({ subject: { type: String, required: true }, body: { type: String, required: true }, at: { type: Date, required: true }, + oID: { type: String, required: true, unique: true } }); export default model('ExecutiveOrders', ExecutiveOrder);