Resolutions

merge-requests/17/head
Hiroyuki 2021-02-07 21:58:26 -04:00
parent eebd5d1e4c
commit 626131bf4e
No known key found for this signature in database
GPG Key ID: C15AC26538975A24
6 changed files with 63 additions and 12 deletions

View File

@ -19,14 +19,14 @@
"@types/jsonwebtoken": "^8.5.0",
"@types/mathjs": "^6.0.7",
"@types/mongoose": "^5.7.19",
"@types/node": "^14.0.1",
"@types/node": "^14.14.25",
"@types/nodemailer": "^6.4.0",
"@types/puppeteer": "^5.4.2",
"@types/puppeteer": "^5.4.3",
"@types/signale": "^1.4.1",
"@types/uuid": "^7.0.3",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"eslint": "^7.0.0",
"eslint": "^7.19.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"typescript": "^3.9.2"
@ -35,27 +35,27 @@
"@google-cloud/text-to-speech": "^3.1.2",
"ari-client": "^2.2.0",
"asterisk-manager": "^0.1.16",
"awesome-phonenumber": "^2.41.0",
"awesome-phonenumber": "^2.45.0",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"brain.js": "^2.0.0-beta.2",
"bull": "^3.18.1",
"bull": "^3.20.1",
"cheerio": "^1.0.0-rc.5",
"cron": "^1.8.2",
"eris": "^0.13.3",
"eris-pagination": "bsian03/eris-pagination",
"eris-pagination": "github:bsian03/eris-pagination",
"express": "^4.17.1",
"helmet": "^3.22.0",
"jsonwebtoken": "^8.5.1",
"mathjs": "^7.6.0",
"moment": "^2.25.3",
"mongoose": "^5.9.13",
"mongoose": "^5.11.15",
"nodemailer": "^6.4.8",
"pluris": "^0.2.5",
"puppeteer": "^5.5.0",
"sd-notify": "^2.8.0",
"signale": "^1.4.0",
"stripe": "^8.120.0",
"stripe": "^8.134.0",
"uuid": "^8.0.0",
"yaml": "^1.9.2"
}

View File

@ -11,7 +11,7 @@ export default class Root extends Route {
}
public bind() {
this.router.post('/executive-orders/new', async (req, res) => {
this.router.post('/executive-orders', async (req, res) => {
if (!req.body.pin) {
return res.status(401).json({
code: this.constants.codes.UNAUTHORIZED,
@ -72,7 +72,7 @@ export default class Root extends Route {
});
});
this.router.post('/motions/new', async (req, res) => {
this.router.post('/motions', async (req, res) => {
if (!req.body.pin) {
return res.status(401).json({
code: this.constants.codes.UNAUTHORIZED,

View File

@ -19,6 +19,7 @@ import {
Promo, PromoInterface,
Rank, RankInterface,
Redirect, RedirectInterface,
Resolution, ResolutionInterface,
Score, ScoreInterface,
ScoreHistorical, ScoreHistoricalInterface,
Staff, StaffInterface,
@ -60,6 +61,7 @@ export default class Client extends eris.Client {
Promo: mongoose.Model<PromoInterface>,
Rank: mongoose.Model<RankInterface>,
Redirect: mongoose.Model<RedirectInterface>,
Resolution: mongoose.Model<ResolutionInterface>,
Score: mongoose.Model<ScoreInterface>,
ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>,
Staff: mongoose.Model<StaffInterface>,
@ -73,7 +75,7 @@ export default class Client extends eris.Client {
this.events = new Collection<Event>();
this.intervals = new Collection<NodeJS.Timeout>();
this.queue = new Queue(this);
this.db = { Customer, CustomerPortal, ExecutiveOrder, File, Member, Merchant, Moderation, Motion, NNTrainingData, Note, PagerNumber, Promo, Rank, Redirect, Score, ScoreHistorical, Staff, Stat, local: { muted: new LocalStorage('muted') } };
this.db = { Customer, CustomerPortal, ExecutiveOrder, File, Member, Merchant, Moderation, Motion, NNTrainingData, Note, PagerNumber, Promo, Rank, Redirect, Resolution, Score, ScoreHistorical, Staff, Stat, local: { muted: new LocalStorage('muted') } };
}
public async loadDatabase() {

View File

@ -26,19 +26,34 @@ export default (client: Client) => {
absent,
},
});
await client.db.Resolution.create({
issuedBy: motion.issuedBy,
subject: motion.subject,
body: motion.body,
at: motion.at,
oID: motion.oID,
voteResults: {
yea: yea.length,
Nay: nay.length,
present,
absent,
},
acceptedAt: Number,
});
const directorDiscord = client.users.get(motion.issuedBy);
const directorProfile = await client.db.Staff.findOne({ userID: motion.issuedBy });
const embed = new RichEmbed();
embed.setAuthor(`${directorDiscord.username}#${directorDiscord.discriminator}, ${directorProfile.pn.join(', ')}`, directorDiscord.avatarURL);
embed.setTitle('Resolution');
embed.setFooter(`${directorProfile.position} | Library of Code sp-us | Board of Directors`, 'https://static.libraryofcode.org/loccommunityadmin.png');
let colour;
if (yea.length > nay.length) colour = '#27b17a';
else if (yea.length === nay.length) colour = '#ffb34d';
else colour = '#ff474a';
embed.setColor(colour);
embed.addField('Motion ID', motion.oID);
embed.setDescription(motion.oID);
embed.addField('Result', `- **Yea:** ${yea.length}\n**Nay:** ${nay.length}\n**Present:** ${present}\n**Absent:** ${absent}\n**Total:** ${present + absent}`);
embed.setTimestamp();

33
src/models/Resolution.ts Normal file
View File

@ -0,0 +1,33 @@
import { Document, model, Schema } from 'mongoose';
export interface ResolutionInterface extends Document {
issuedBy: string;
subject: string;
body: string;
at: Date;
oID: string;
voteResults: {
yea: number;
nay: number;
present: number;
absent: number;
};
acceptedAt: number;
}
const Resolution = new Schema({
issuedBy: { type: String, required: true },
subject: { type: String, required: true },
body: { type: String, required: true },
at: { type: Date, required: true },
oID: { type: String, required: true, unique: true },
voteResults: {
yea: Number,
Nay: Number,
present: Number,
absent: Number,
},
acceptedAt: Number,
});
export default model<ResolutionInterface>('Resolutions', Resolution);

View File

@ -12,6 +12,7 @@ export { default as PagerNumber, PagerNumberInterface, PagerNumberRaw } from './
export { default as Promo, PromoInterface } from './Promo';
export { default as Rank, RankInterface } from './Rank';
export { default as Redirect, RedirectInterface, RedirectRaw } from './Redirect';
export { default as Resolution, ResolutionInterface } from './Resolution';
export { default as Score, ScoreInterface, ScoreInterfaceRaw } from './Score';
export { default as ScoreHistorical, ScoreHistoricalInterface } from './ScoreHistorical';
export { default as Staff, StaffInterface } from './Staff';