diff --git a/src/api/board.ins/routes/root.ts b/src/api/board.ins/routes/root.ts index 95e8366..ee29a43 100644 --- a/src/api/board.ins/routes/root.ts +++ b/src/api/board.ins/routes/root.ts @@ -21,7 +21,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { return res.status(403).json({ @@ -78,7 +78,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { return res.status(403).json({ @@ -136,7 +136,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { return res.status(401).json({ @@ -179,7 +179,7 @@ export default class Root extends Route { await procMessage.addReaction(this.server.client.util.emojis.ERROR); await procMessage.getReaction('🙋'); - const proc = await this.server.client.db.Proclamation.create({ + const proclamation = await this.server.client.db.Proclamation.create({ issuer: director.userID, subject: req.body.subject, body: req.body.body, @@ -191,65 +191,7 @@ export default class Root extends Route { res.status(200).json({ code: this.constants.codes.SUCCESS, - message: `Created new Proclamation with ID ${proc.oID} by ${directorDiscord.username}#${directorDiscord.discriminator}, ${directorInformation.pn.join(', ')}.`, - }); - }); - - this.router.post('/resolution', 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 }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); - const directorDiscord = staffGuild.members.get(director.userID); - - if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { - return res.status(403).json({ - code: this.constants.codes.UNAUTHORIZED, - message: this.constants.messages.UNAUTHORIZED, - }); - } - - if (!req.body.subject || !req.body.body) { - return res.status(400).json({ - code: this.constants.codes.CLIENT_ERROR, - message: this.constants.messages.CLIENT_ERROR, - }); - } - - const resolutionID = genUUID(); - - const directorInformation = await this.server.client.db.Staff.findOne({ userID: director.userID }); - - const embed = new RichEmbed(); - embed.setTitle('Resolution'); - embed.setAuthor(`${directorDiscord.username}#${directorDiscord.discriminator}, ${directorInformation.pn.join(', ')}`, directorDiscord.avatarURL); - embed.setColor('#29be74'); - embed.addField('Subject', req.body.subject); - embed.addField('Body', req.body.body); - embed.setDescription(resolutionID); - embed.setTimestamp(new Date()); - - const channel = this.server.client.getChannel('807444198969835550'); - const msg = await channel.createMessage({ embed }); - - const resolution = await this.server.client.db.Resolution.create({ - issuer: director.userID, - subject: req.body.subject, - body: req.body.body, - at: new Date(), - oID: resolutionID, - processed: false, - msg: msg.id, - }); - - res.status(200).json({ - code: this.constants.codes.SUCCESS, - message: `Created new Resolution with ID ${resolution.oID} by ${directorDiscord.username}#${directorDiscord.discriminator}, ${directorInformation.pn.join(', ')}.`, + message: `Created new Proclamation with ID ${proclamation.oID} by ${directorDiscord.username}#${directorDiscord.discriminator}, ${directorInformation.pn.join(', ')}.`, }); }); @@ -262,7 +204,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { return res.status(403).json({ @@ -285,7 +227,16 @@ export default class Root extends Route { }); } - await this.server.client.db.ExecutiveOrder.deleteOne({ oID: req.params.id }); + const executiveOrder = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id }); + + if (!['278620217221971968', executiveOrder.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + + await executiveOrder.delete(); res.status(200).json({ message: `Executive Order with ID ${req.params.id} deleted.` }); }); @@ -299,7 +250,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { return res.status(403).json({ @@ -314,54 +265,28 @@ export default class Root extends Route { message: this.constants.messages.CLIENT_ERROR, }); } - if (!(await this.server.client.db.Resolution.exists({ oID: req.params.id }))) { + + if (!(await this.server.client.db.Motion.exists({ oID: req.params.id }))) { return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND, }); } - await this.server.client.db.Motion.deleteOne({ oID: req.params.id }); + const motion = await this.server.client.db.Motion.findOne({ oID: req.params.id }); + + if (!['278620217221971968', motion.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + + await motion.delete(); res.status(200).json({ message: `Motion with ID ${req.params.id} deleted.` }); }); - this.router.delete('/resolution/:id', 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 }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); - - if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { - return res.status(403).json({ - code: this.constants.codes.UNAUTHORIZED, - message: this.constants.messages.UNAUTHORIZED, - }); - } - - if (!req.params.id) { - return res.status(400).json({ - code: this.constants.codes.CLIENT_ERROR, - message: this.constants.messages.CLIENT_ERROR, - }); - } - if (!(await this.server.client.db.Resolution.exists({ oID: req.params.id }))) { - return res.status(404).json({ - code: this.constants.codes.NOT_FOUND, - message: this.constants.messages.NOT_FOUND, - }); - } - - await this.server.client.db.Resolution.deleteOne({ oID: req.params.id }); - - res.status(200).json({ message: `Resolution with ID ${req.params.id} deleted.` }); - }); - this.router.delete('/proc/:id', async (req, res) => { if (!req.body.pin) { return res.status(401).json({ @@ -371,7 +296,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) { return res.status(403).json({ @@ -393,7 +318,16 @@ export default class Root extends Route { }); } - await this.server.client.db.Proclamation.deleteOne({ oID: req.params.id }); + const proclamation = await this.server.client.db.Proclamation.findOne({ oID: req.params.id }); + + if (!['278620217221971968', proclamation.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + + await proclamation.delete(); res.status(200).json({ message: `Proclamation with ID ${req.params.id} deleted.` }); }); @@ -412,15 +346,9 @@ export default class Root extends Route { }); } - const executiveOrder = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id }); + const executiveOrder = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id }).lean(); - res.status(200).json({ - issuer: executiveOrder.issuer, - id: executiveOrder.oID, - subject: executiveOrder.subject, - body: executiveOrder.body, - at: new Date(executiveOrder.at), - }); + res.status(200).json(executiveOrder); }); this.router.get('/motion/:id', async (req, res) => { @@ -437,15 +365,28 @@ export default class Root extends Route { }); } - const motion = await this.server.client.db.Motion.findOne({ oID: req.params.id }); + const motion = await this.server.client.db.Motion.findOne({ oID: req.params.id }).lean(); - res.status(200).json({ - issuer: motion.issuer, - id: motion.oID, - subject: motion.subject, - body: motion.body, - at: new Date(motion.at), - }); + res.status(200).json(motion); + }); + + this.router.get('/proc/:id', async (req: Request, res: Response) => { + if (!req.params.id) { + return res.status(400).json({ + code: this.constants.codes.CLIENT_ERROR, + message: this.constants.messages.CLIENT_ERROR, + }); + } + if (!(await this.server.client.db.Proclamation.exists({ oID: req.params.id }))) { + return res.status(404).json({ + code: this.constants.codes.NOT_FOUND, + message: this.constants.messages.NOT_FOUND, + }); + } + + const proclamation = await this.server.client.db.Proclamation.findOne({ oID: req.params.id }).lean(); + + res.status(200).json(proclamation); }); this.router.get('/resolution/:id', async (req, res) => { @@ -462,89 +403,9 @@ export default class Root extends Route { }); } - const resolution = await this.server.client.db.Resolution.findOne({ oID: req.params.id }); + const resolution = await this.server.client.db.Resolution.findOne({ oID: req.params.id }).lean(); - res.status(200).json({ - issuer: resolution.issuer, - id: resolution.oID, - subject: resolution.subject, - body: resolution.body, - at: new Date(resolution.at), - approvedAt: resolution.acceptedAt || null, - results: resolution.results || null, - }); - }); - - this.router.get('/proc/:id', async (req: Request, res: Response) => { - const proclamation = await this.server.client.db.Proclamation.findOne({ oID: req.params.id }).lean(); - - res.status(200).send({ - proclamation, - }); - }); - - this.router.patch('/proc/:id', 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 }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); - const directorDiscord = staffGuild.members.get(director.userID); - - if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { - return res.status(403).json({ - code: this.constants.codes.UNAUTHORIZED, - message: this.constants.messages.UNAUTHORIZED, - }); - } - - if (!req.params.id) { - return res.status(400).json({ - code: this.constants.codes.CLIENT_ERROR, - message: this.constants.messages.CLIENT_ERROR, - }); - } - if (!(await this.server.client.db.Proclamation.exists({ oID: req.params.id }))) { - return res.status(404).json({ - code: this.constants.codes.NOT_FOUND, - message: this.constants.messages.NOT_FOUND, - }); - } - if (!req.body.subject && !req.body.body) { - return res.status(400).json({ - code: this.constants.codes.CLIENT_ERROR, - message: this.constants.messages.CLIENT_ERROR, - }); - } - - const proclamation = await this.server.client.db.Proclamation.findOne({ oID: req.params.id }); - await proclamation.updateOne({ - subject: req.body.subject || proclamation.subject, - body: req.body.body || proclamation.body, - }); - - if (proclamation.subject !== req.body.subject || proclamation.body !== req.body.body) { - const directorStaffProfile = await this.server.client.db.Staff.findOne({ userID: directorDiscord.id }); - - const embed = new RichEmbed(); - embed.setTitle('Proclamation'); - embed.setAuthor(`${directorDiscord.username}#${directorDiscord.discriminator}, ${directorStaffProfile.pn.join(', ')}`, directorDiscord.avatarURL); - embed.setColor('#66e1ff'); - embed.addField('Subject', req.body.subject || proclamation.subject); - embed.addField('Body', req.body.body || proclamation.body); - embed.setDescription(req.params.id); - embed.setTimestamp(new Date()); - - const channel = this.server.client.getChannel('807444198969835550'); - const procMessage = await channel.getMessage(proclamation.msg); - await procMessage.edit({ embed }); - } - - res.status(200).json({ message: `Updated Proclamation with ID ${proclamation.oID}.` }); + res.status(200).json(resolution); }); this.router.patch('/eo/:id', async (req, res) => { @@ -556,7 +417,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); const directorDiscord = staffGuild.members.get(director.userID); if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { @@ -586,6 +447,14 @@ export default class Root extends Route { } const executiveOrder = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id }); + + if (!['278620217221971968', executiveOrder.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + await executiveOrder.updateOne({ subject: req.body.subject || executiveOrder.subject, body: req.body.body || executiveOrder.body, @@ -620,7 +489,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); const directorDiscord = staffGuild.members.get(director.userID); if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { @@ -650,6 +519,14 @@ export default class Root extends Route { } const motion = await this.server.client.db.Motion.findOne({ oID: req.params.id }); + + if (!['278620217221971968', motion.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + await motion.updateOne({ subject: req.body.subject || motion.subject, body: req.body.body || motion.body, @@ -675,6 +552,78 @@ export default class Root extends Route { res.status(200).json({ message: `Updated Motion with ID ${motion.oID}.` }); }); + this.router.patch('/proc/:id', 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 }); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); + const directorDiscord = staffGuild.members.get(director.userID); + + if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + + if (!req.params.id) { + return res.status(400).json({ + code: this.constants.codes.CLIENT_ERROR, + message: this.constants.messages.CLIENT_ERROR, + }); + } + if (!(await this.server.client.db.Proclamation.exists({ oID: req.params.id }))) { + return res.status(404).json({ + code: this.constants.codes.NOT_FOUND, + message: this.constants.messages.NOT_FOUND, + }); + } + if (!req.body.subject && !req.body.body) { + return res.status(400).json({ + code: this.constants.codes.CLIENT_ERROR, + message: this.constants.messages.CLIENT_ERROR, + }); + } + + const proclamation = await this.server.client.db.Proclamation.findOne({ oID: req.params.id }); + + if (!['278620217221971968', proclamation.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + + await proclamation.updateOne({ + subject: req.body.subject || proclamation.subject, + body: req.body.body || proclamation.body, + }); + + if (proclamation.subject !== req.body.subject || proclamation.body !== req.body.body) { + const directorStaffProfile = await this.server.client.db.Staff.findOne({ userID: directorDiscord.id }); + + const embed = new RichEmbed(); + embed.setTitle('Proclamation'); + embed.setAuthor(`${directorDiscord.username}#${directorDiscord.discriminator}, ${directorStaffProfile.pn.join(', ')}`, directorDiscord.avatarURL); + embed.setColor('#66e1ff'); + embed.addField('Subject', req.body.subject || proclamation.subject); + embed.addField('Body', req.body.body || proclamation.body); + embed.setDescription(req.params.id); + embed.setTimestamp(new Date()); + + const channel = this.server.client.getChannel('807444198969835550'); + const procMessage = await channel.getMessage(proclamation.msg); + await procMessage.edit({ embed }); + } + + res.status(200).json({ message: `Updated Proclamation with ID ${proclamation.oID}.` }); + }); + this.router.patch('/resolution/:id', async (req, res) => { if (!req.body.pin) { return res.status(401).json({ @@ -684,7 +633,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); const directorDiscord = staffGuild.members.get(director.userID); if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { @@ -714,6 +663,14 @@ export default class Root extends Route { } const resolution = await this.server.client.db.Resolution.findOne({ oID: req.params.id }); + + if (!['278620217221971968', resolution.issuer].includes(director.userID)) { + return res.status(403).json({ + code: this.constants.codes.UNAUTHORIZED, + message: this.constants.messages.UNAUTHORIZED, + }); + } + await resolution.updateOne({ subject: req.body.subject || resolution.subject, body: req.body.body || resolution.body, @@ -723,7 +680,7 @@ export default class Root extends Route { const directorStaffProfile = await this.server.client.db.Staff.findOne({ userID: directorDiscord.id }); const embed = new RichEmbed(); - embed.setTitle('Executive Order'); + embed.setTitle('Resolution'); embed.setAuthor(`${directorDiscord.username}#${directorDiscord.discriminator}, ${directorStaffProfile.pn.join(', ')}`, directorDiscord.avatarURL); embed.setColor('#66e1ff'); embed.addField('Subject', req.body.subject || resolution.subject); @@ -743,13 +700,13 @@ export default class Root extends Route { const executiveOrders = await this.server.client.db.ExecutiveOrder.find().lean(); - res.status(200).json({ executiveOrders }); + res.status(200).json(executiveOrders); }); this.router.get('/motion', async (_req, res) => { const motions = await this.server.client.db.Motion.find().lean(); - res.status(200).json({ motions }); + res.status(200).json(motions); }); this.router.get('/proc', async (_req: Request, res: Response) => { @@ -758,29 +715,10 @@ export default class Root extends Route { res.status(200).send({ proclamations }); }); - this.router.get('/eo', async (_req, res) => { - const executiveOrders = await this.server.client.db.ExecutiveOrder.find().lean(); - - - res.status(200).json({ executiveOrders }); - }); - - this.router.get('/motion', async (_req, res) => { - const motions = await this.server.client.db.Motion.find().lean(); - - res.status(200).json({ motions }); - }); - this.router.get('/resolution', async (_req, res) => { const resolutions = await this.server.client.db.Resolution.find().lean(); - res.status(200).json({ resolutions }); - }); - - this.router.get('/resolution', async (_req, res) => { - const resolutions = await this.server.client.db.Resolution.find().lean(); - - res.status(200).json({ resolutions }); + res.status(200).json(resolutions); }); this.router.patch('/motion/confirm', async (req, res) => { @@ -792,7 +730,7 @@ export default class Root extends Route { } const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); - const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794'); + const staffGuild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); const directorDiscord = staffGuild.members.get(director.userID); if (!director || !directorDiscord?.roles?.includes('662163685439045632')) { diff --git a/src/events/messageReactionAdd.ts b/src/events/messageReactionAdd.ts index c00fcbf..478209a 100644 --- a/src/events/messageReactionAdd.ts +++ b/src/events/messageReactionAdd.ts @@ -24,8 +24,8 @@ export default class MessageReactionAdd extends Event { const nay = await message.getReaction(this.client.util.emojis.ERROR); const present = await message.getReaction('🙋'); const totalDirectors = 6; - const proc = await this.client.db.Proclamation.findOne({ msg: message.id }); - const processed = totalDirectors === (yea.length + nay.length + present.length) || Date.now() - proc.at > 604800000; + const proclamation = await this.client.db.Proclamation.findOne({ msg: message.id }); + const processed = totalDirectors === (yea.length + nay.length + present.length) || Date.now() - proclamation.at > 604800000; const absent = totalDirectors - (yea.length + nay.length + present.length); await this.client.db.Proclamation.updateOne({ msg: message.id }, { @@ -40,18 +40,18 @@ export default class MessageReactionAdd extends Event { const inTheMajority = yea.length > nay.length + present.length; if (processed) { - const author = this.client.users.get(proc.issuer) || await this.client.getRESTUser(proc.issuer); + const author = this.client.users.get(proclamation.issuer) || await this.client.getRESTUser(proclamation.issuer); if (inTheMajority) { - await author.createMessage(`__**Proclamation Majority Vote Received**__\nThe Proclamation you created at Library of Code sp-us, titled **${proc.subject}** (\`${proc.oID}\`) received the majority vote.`); - await message.channel.createMessage(`__**Proclamation Results**__\nProclamation issued by ${author.mention} **received** the majority vote. Proclamation ID: ${proc.oID}\n\n__Results:__\n**Yea:** ${yea.length}\n**Nay:** ${nay.length}\n**Present:** ${present.length}\n**Absent:** ${absent}`); + await author.createMessage(`__**Proclamation Majority Vote Received**__\nThe Proclamation you created at Library of Code sp-us, titled **${proclamation.subject}** (\`${proclamation.oID}\`) received the majority vote.`); + await message.channel.createMessage(`__**Proclamation Results**__\nProclamation issued by ${author.mention} **received** the majority vote. Proclamation ID: ${proclamation.oID}\n\n__Results:__\n**Yea:** ${yea.length}\n**Nay:** ${nay.length}\n**Present:** ${present.length}\n**Absent:** ${absent}`); } else { - await author.createMessage(`__**Proclamation Majority Vote Lost**__\nThe Proclamation you created at Library of Code sp-us, titled **${proc.subject}** (\`${proc.oID}\`) lost the majority vote.`); - await message.channel.createMessage(`__**Proclamation Results**__\nProclamation issued by ${author.mention} **lost** the majority vote. Proclamation ID: ${proc.oID}\n\n__Results:__\n**Yea:** ${yea.length}\n**Nay:** ${nay.length}\n**Present:** ${present.length}\n**Absent:** ${absent}`); + await author.createMessage(`__**Proclamation Majority Vote Lost**__\nThe Proclamation you created at Library of Code sp-us, titled **${proclamation.subject}** (\`${proclamation.oID}\`) lost the majority vote.`); + await message.channel.createMessage(`__**Proclamation Results**__\nProclamation issued by ${author.mention} **lost** the majority vote. Proclamation ID: ${proclamation.oID}\n\n__Results:__\n**Yea:** ${yea.length}\n**Nay:** ${nay.length}\n**Present:** ${present.length}\n**Absent:** ${absent}`); } } - await reactor.user.createMessage(`__**Vote Recorded**\nYour vote on the proclamation with ID \`${proc.id}\` at Library of Code sp-us was successfully recorded.`); + await reactor.user.createMessage(`__**Vote Recorded**\nYour vote on the proclamation with ID \`${proclamation.id}\` at Library of Code sp-us was successfully recorded.`); } } }