Resolutions
parent
eebd5d1e4c
commit
626131bf4e
16
package.json
16
package.json
|
@ -19,14 +19,14 @@
|
||||||
"@types/jsonwebtoken": "^8.5.0",
|
"@types/jsonwebtoken": "^8.5.0",
|
||||||
"@types/mathjs": "^6.0.7",
|
"@types/mathjs": "^6.0.7",
|
||||||
"@types/mongoose": "^5.7.19",
|
"@types/mongoose": "^5.7.19",
|
||||||
"@types/node": "^14.0.1",
|
"@types/node": "^14.14.25",
|
||||||
"@types/nodemailer": "^6.4.0",
|
"@types/nodemailer": "^6.4.0",
|
||||||
"@types/puppeteer": "^5.4.2",
|
"@types/puppeteer": "^5.4.3",
|
||||||
"@types/signale": "^1.4.1",
|
"@types/signale": "^1.4.1",
|
||||||
"@types/uuid": "^7.0.3",
|
"@types/uuid": "^7.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
||||||
"@typescript-eslint/parser": "^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-config-airbnb-base": "^14.1.0",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
|
@ -35,27 +35,27 @@
|
||||||
"@google-cloud/text-to-speech": "^3.1.2",
|
"@google-cloud/text-to-speech": "^3.1.2",
|
||||||
"ari-client": "^2.2.0",
|
"ari-client": "^2.2.0",
|
||||||
"asterisk-manager": "^0.1.16",
|
"asterisk-manager": "^0.1.16",
|
||||||
"awesome-phonenumber": "^2.41.0",
|
"awesome-phonenumber": "^2.45.0",
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"brain.js": "^2.0.0-beta.2",
|
"brain.js": "^2.0.0-beta.2",
|
||||||
"bull": "^3.18.1",
|
"bull": "^3.20.1",
|
||||||
"cheerio": "^1.0.0-rc.5",
|
"cheerio": "^1.0.0-rc.5",
|
||||||
"cron": "^1.8.2",
|
"cron": "^1.8.2",
|
||||||
"eris": "^0.13.3",
|
"eris": "^0.13.3",
|
||||||
"eris-pagination": "bsian03/eris-pagination",
|
"eris-pagination": "github:bsian03/eris-pagination",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"helmet": "^3.22.0",
|
"helmet": "^3.22.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"mathjs": "^7.6.0",
|
"mathjs": "^7.6.0",
|
||||||
"moment": "^2.25.3",
|
"moment": "^2.25.3",
|
||||||
"mongoose": "^5.9.13",
|
"mongoose": "^5.11.15",
|
||||||
"nodemailer": "^6.4.8",
|
"nodemailer": "^6.4.8",
|
||||||
"pluris": "^0.2.5",
|
"pluris": "^0.2.5",
|
||||||
"puppeteer": "^5.5.0",
|
"puppeteer": "^5.5.0",
|
||||||
"sd-notify": "^2.8.0",
|
"sd-notify": "^2.8.0",
|
||||||
"signale": "^1.4.0",
|
"signale": "^1.4.0",
|
||||||
"stripe": "^8.120.0",
|
"stripe": "^8.134.0",
|
||||||
"uuid": "^8.0.0",
|
"uuid": "^8.0.0",
|
||||||
"yaml": "^1.9.2"
|
"yaml": "^1.9.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default class Root extends Route {
|
||||||
}
|
}
|
||||||
|
|
||||||
public bind() {
|
public bind() {
|
||||||
this.router.post('/executive-orders/new', async (req, res) => {
|
this.router.post('/executive-orders', async (req, res) => {
|
||||||
if (!req.body.pin) {
|
if (!req.body.pin) {
|
||||||
return res.status(401).json({
|
return res.status(401).json({
|
||||||
code: this.constants.codes.UNAUTHORIZED,
|
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) {
|
if (!req.body.pin) {
|
||||||
return res.status(401).json({
|
return res.status(401).json({
|
||||||
code: this.constants.codes.UNAUTHORIZED,
|
code: this.constants.codes.UNAUTHORIZED,
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
Promo, PromoInterface,
|
Promo, PromoInterface,
|
||||||
Rank, RankInterface,
|
Rank, RankInterface,
|
||||||
Redirect, RedirectInterface,
|
Redirect, RedirectInterface,
|
||||||
|
Resolution, ResolutionInterface,
|
||||||
Score, ScoreInterface,
|
Score, ScoreInterface,
|
||||||
ScoreHistorical, ScoreHistoricalInterface,
|
ScoreHistorical, ScoreHistoricalInterface,
|
||||||
Staff, StaffInterface,
|
Staff, StaffInterface,
|
||||||
|
@ -60,6 +61,7 @@ export default class Client extends eris.Client {
|
||||||
Promo: mongoose.Model<PromoInterface>,
|
Promo: mongoose.Model<PromoInterface>,
|
||||||
Rank: mongoose.Model<RankInterface>,
|
Rank: mongoose.Model<RankInterface>,
|
||||||
Redirect: mongoose.Model<RedirectInterface>,
|
Redirect: mongoose.Model<RedirectInterface>,
|
||||||
|
Resolution: mongoose.Model<ResolutionInterface>,
|
||||||
Score: mongoose.Model<ScoreInterface>,
|
Score: mongoose.Model<ScoreInterface>,
|
||||||
ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>,
|
ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>,
|
||||||
Staff: mongoose.Model<StaffInterface>,
|
Staff: mongoose.Model<StaffInterface>,
|
||||||
|
@ -73,7 +75,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, 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() {
|
public async loadDatabase() {
|
||||||
|
|
|
@ -26,19 +26,34 @@ export default (client: Client) => {
|
||||||
absent,
|
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 directorDiscord = client.users.get(motion.issuedBy);
|
||||||
const directorProfile = await client.db.Staff.findOne({ userID: motion.issuedBy });
|
const directorProfile = await client.db.Staff.findOne({ userID: motion.issuedBy });
|
||||||
|
|
||||||
const embed = new RichEmbed();
|
const embed = new RichEmbed();
|
||||||
embed.setAuthor(`${directorDiscord.username}#${directorDiscord.discriminator}, ${directorProfile.pn.join(', ')}`, directorDiscord.avatarURL);
|
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');
|
embed.setFooter(`${directorProfile.position} | Library of Code sp-us | Board of Directors`, 'https://static.libraryofcode.org/loccommunityadmin.png');
|
||||||
let colour;
|
let colour;
|
||||||
if (yea.length > nay.length) colour = '#27b17a';
|
if (yea.length > nay.length) colour = '#27b17a';
|
||||||
else if (yea.length === nay.length) colour = '#ffb34d';
|
else if (yea.length === nay.length) colour = '#ffb34d';
|
||||||
else colour = '#ff474a';
|
else colour = '#ff474a';
|
||||||
embed.setColor(colour);
|
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.addField('Result', `- **Yea:** ${yea.length}\n**Nay:** ${nay.length}\n**Present:** ${present}\n**Absent:** ${absent}\n**Total:** ${present + absent}`);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
@ -12,6 +12,7 @@ export { default as PagerNumber, PagerNumberInterface, PagerNumberRaw } from './
|
||||||
export { default as Promo, PromoInterface } from './Promo';
|
export { default as Promo, PromoInterface } from './Promo';
|
||||||
export { default as Rank, RankInterface } from './Rank';
|
export { default as Rank, RankInterface } from './Rank';
|
||||||
export { default as Redirect, RedirectInterface, RedirectRaw } from './Redirect';
|
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 Score, ScoreInterface, ScoreInterfaceRaw } from './Score';
|
||||||
export { default as ScoreHistorical, ScoreHistoricalInterface } from './ScoreHistorical';
|
export { default as ScoreHistorical, ScoreHistoricalInterface } from './ScoreHistorical';
|
||||||
export { default as Staff, StaffInterface } from './Staff';
|
export { default as Staff, StaffInterface } from './Staff';
|
||||||
|
|
Loading…
Reference in New Issue