database logic rewrite
parent
40aef4123b
commit
b5613a43ff
|
@ -42,7 +42,8 @@
|
|||
"no-multiple-empty-lines": "off",
|
||||
"consistent-return": "off",
|
||||
"no-continue": "off",
|
||||
"no-plusplus": "off"
|
||||
"no-plusplus": "off",
|
||||
"no-undef": "off"
|
||||
},
|
||||
"ignorePatterns": "**/*.js"
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,6 +41,7 @@
|
|||
"brain.js": "^2.0.0-beta.4",
|
||||
"bull": "^4.1.1",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"cr-db": "git+https://gitlab.libraryofcode.org/engineering/community-relations/database.git",
|
||||
"cron": "^1.8.2",
|
||||
"eris": "^0.16.1",
|
||||
"eris-pagination": "github:libraryofcode/eris-pagination",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Guild, GuildTextableChannel, Member, TextChannel } from 'eris';
|
||||
import { v4 as genUUID } from 'uuid';
|
||||
import { Request } from 'express';
|
||||
import { Staff } from 'cr-db/mongodb';
|
||||
import { RichEmbed, Route, Server } from '../../../class';
|
||||
import { StaffInterface } from '../../../models';
|
||||
|
||||
export default class Root extends Route {
|
||||
constructor(server: Server) {
|
||||
|
@ -33,7 +33,7 @@ export default class Root extends Route {
|
|||
private async authenticate(req: Request) {
|
||||
if (!req.headers.authorization) return false;
|
||||
|
||||
const users = await this.server.client.db.Score.find();
|
||||
const users = await this.server.client.db.mongo.Score.find();
|
||||
const director = users.find((user) => user.pin.join('-') === req.headers.authorization);
|
||||
if (!director) return false;
|
||||
|
||||
|
@ -41,7 +41,7 @@ export default class Root extends Route {
|
|||
if (!member) return false;
|
||||
if (!member.roles.includes(this.directorRole)) return false;
|
||||
|
||||
const staffProfile = await this.server.client.db.Staff.findOne({ userID: member.id });
|
||||
const staffProfile = await this.server.client.db.mongo.Staff.findOne({ userID: member.id });
|
||||
|
||||
return { member, director: staffProfile };
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export default class Root extends Route {
|
|||
id: string,
|
||||
type: 'eo' | 'motion' | 'proc' | 'res' | 'confirmMotion',
|
||||
director: {
|
||||
user: StaffInterface,
|
||||
user: Staff,
|
||||
member: Member
|
||||
},
|
||||
payload: {
|
||||
|
@ -156,16 +156,16 @@ export default class Root extends Route {
|
|||
const page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
|
||||
|
||||
const counts = {
|
||||
eo: await this.server.client.db.ExecutiveOrder.countDocuments(),
|
||||
motion: await this.server.client.db.Motion.countDocuments(),
|
||||
proc: await this.server.client.db.Proclamation.countDocuments(),
|
||||
resolution: await this.server.client.db.Resolution.countDocuments(),
|
||||
eo: await this.server.client.db.mongo.ExecutiveOrder.countDocuments(),
|
||||
motion: await this.server.client.db.mongo.Motion.countDocuments(),
|
||||
proc: await this.server.client.db.mongo.Proclamation.countDocuments(),
|
||||
resolution: await this.server.client.db.mongo.Resolution.countDocuments(),
|
||||
};
|
||||
|
||||
const eo = await this.server.client.db.ExecutiveOrder.find().skip(page * 4);
|
||||
const motion = await this.server.client.db.Motion.find().skip(page * 4);
|
||||
const proc = await this.server.client.db.Proclamation.find().skip(page * 4);
|
||||
const resolution = await this.server.client.db.Resolution.find().skip(page * 4);
|
||||
const eo = await this.server.client.db.mongo.ExecutiveOrder.find().skip(page * 4);
|
||||
const motion = await this.server.client.db.mongo.Motion.find().skip(page * 4);
|
||||
const proc = await this.server.client.db.mongo.Proclamation.find().skip(page * 4);
|
||||
const resolution = await this.server.client.db.mongo.Resolution.find().skip(page * 4);
|
||||
|
||||
const returned: {
|
||||
id: string;
|
||||
|
@ -291,7 +291,7 @@ export default class Root extends Route {
|
|||
const msg = await this.brsVotingChannel.createMessage({ embed });
|
||||
await this.brsLogChannel.createMessage({ embed });
|
||||
|
||||
const eo = await this.server.client.db.ExecutiveOrder.create({
|
||||
const eo = await this.server.client.db.mongo.ExecutiveOrder.create({
|
||||
issuer: authenticated.director.userID,
|
||||
subject: req.body.subject,
|
||||
body: req.body.body,
|
||||
|
@ -338,7 +338,7 @@ export default class Root extends Route {
|
|||
const msg = await this.brsVotingChannel.createMessage({ embed });
|
||||
await this.brsLogChannel.createMessage({ embed });
|
||||
|
||||
const motion = await this.server.client.db.Motion.create({
|
||||
const motion = await this.server.client.db.mongo.Motion.create({
|
||||
issuer: authenticated.director.userID,
|
||||
subject: req.body.subject,
|
||||
body: req.body.body,
|
||||
|
@ -388,7 +388,7 @@ export default class Root extends Route {
|
|||
await msg.addReaction('modError:578750737920688128');
|
||||
await msg.addReaction('🙋');
|
||||
|
||||
const proc = await this.server.client.db.Proclamation.create({
|
||||
const proc = await this.server.client.db.mongo.Proclamation.create({
|
||||
issuer: authenticated.director.userID,
|
||||
subject: req.body.subject,
|
||||
body: req.body.body,
|
||||
|
@ -420,7 +420,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
const eo = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id });
|
||||
const eo = await this.server.client.db.mongo.ExecutiveOrder.findOne({ oID: req.params.id });
|
||||
|
||||
if (!eo) {
|
||||
return res.status(404).json({
|
||||
|
@ -436,7 +436,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
await this.server.client.db.ExecutiveOrder.deleteOne({ _id: eo._id });
|
||||
await this.server.client.db.mongo.ExecutiveOrder.deleteOne({ _id: eo._id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -453,7 +453,7 @@ 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.mongo.Motion.findOne({ oID: req.params.id });
|
||||
|
||||
if (!motion) {
|
||||
return res.status(404).json({
|
||||
|
@ -469,7 +469,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
await this.server.client.db.Motion.deleteOne({ _id: motion._id });
|
||||
await this.server.client.db.mongo.Motion.deleteOne({ _id: motion._id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -486,7 +486,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
const proc = await this.server.client.db.Proclamation.findOne({ oID: req.params.id });
|
||||
const proc = await this.server.client.db.mongo.Proclamation.findOne({ oID: req.params.id });
|
||||
|
||||
if (!proc) {
|
||||
return res.status(404).json({
|
||||
|
@ -502,7 +502,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
await this.server.client.db.Proclamation.deleteOne({ _id: proc._id });
|
||||
await this.server.client.db.mongo.Proclamation.deleteOne({ _id: proc._id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -511,7 +511,7 @@ export default class Root extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/eo/:id', async (req, res) => {
|
||||
const eo = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id });
|
||||
const eo = await this.server.client.db.mongo.ExecutiveOrder.findOne({ oID: req.params.id });
|
||||
|
||||
if (!eo) {
|
||||
return res.status(404).json({
|
||||
|
@ -521,7 +521,7 @@ export default class Root extends Route {
|
|||
}
|
||||
|
||||
const issuer = this.guild.members.get(eo.issuer);
|
||||
const director = await this.server.client.db.Staff.findOne({ userID: issuer.id });
|
||||
const director = await this.server.client.db.mongo.Staff.findOne({ userID: issuer.id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -540,7 +540,7 @@ export default class Root extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/motion/:id', async (req, res) => {
|
||||
const motion = await this.server.client.db.Motion.findOne({ oID: req.params.id });
|
||||
const motion = await this.server.client.db.mongo.Motion.findOne({ oID: req.params.id });
|
||||
|
||||
if (!motion) {
|
||||
return res.status(404).json({
|
||||
|
@ -550,7 +550,7 @@ export default class Root extends Route {
|
|||
}
|
||||
|
||||
const issuer = this.guild.members.get(motion.issuer);
|
||||
const director = await this.server.client.db.Staff.findOne({ userID: issuer.id });
|
||||
const director = await this.server.client.db.mongo.Staff.findOne({ userID: issuer.id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -571,7 +571,7 @@ export default class Root extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/proc/:id', async (req, res) => {
|
||||
const proc = await this.server.client.db.Proclamation.findOne({ oID: req.params.id });
|
||||
const proc = await this.server.client.db.mongo.Proclamation.findOne({ oID: req.params.id });
|
||||
|
||||
if (!proc) {
|
||||
return res.status(404).json({
|
||||
|
@ -581,7 +581,7 @@ export default class Root extends Route {
|
|||
}
|
||||
|
||||
const issuer = this.guild.members.get(proc.issuer);
|
||||
const director = await this.server.client.db.Staff.findOne({ userID: issuer.id });
|
||||
const director = await this.server.client.db.mongo.Staff.findOne({ userID: issuer.id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -602,7 +602,7 @@ export default class Root extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/resolution/:id', async (req, res) => {
|
||||
const resolution = await this.server.client.db.Resolution.findOne({ oID: req.params.id });
|
||||
const resolution = await this.server.client.db.mongo.Resolution.findOne({ oID: req.params.id });
|
||||
|
||||
if (!resolution) {
|
||||
return res.status(404).json({
|
||||
|
@ -612,7 +612,7 @@ export default class Root extends Route {
|
|||
}
|
||||
|
||||
const issuer = this.guild.members.get(resolution.issuer);
|
||||
const director = await this.server.client.db.Staff.findOne({ userID: issuer.id });
|
||||
const director = await this.server.client.db.mongo.Staff.findOne({ userID: issuer.id });
|
||||
|
||||
res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -640,7 +640,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
const eo = await this.server.client.db.ExecutiveOrder.findOne({ oID: req.params.id });
|
||||
const eo = await this.server.client.db.mongo.ExecutiveOrder.findOne({ oID: req.params.id });
|
||||
|
||||
if (!eo) {
|
||||
return res.status(404).json({
|
||||
|
@ -694,7 +694,7 @@ 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.mongo.Motion.findOne({ oID: req.params.id });
|
||||
|
||||
if (!motion) {
|
||||
return res.status(404).json({
|
||||
|
@ -748,7 +748,7 @@ export default class Root extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
const proc = await this.server.client.db.Proclamation.findOne({ oID: req.params.id });
|
||||
const proc = await this.server.client.db.mongo.Proclamation.findOne({ oID: req.params.id });
|
||||
|
||||
if (!proc) {
|
||||
return res.status(404).json({
|
||||
|
@ -802,7 +802,7 @@ 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.mongo.Resolution.findOne({ oID: req.params.id });
|
||||
|
||||
if (!resolution) {
|
||||
return res.status(404).json({
|
||||
|
@ -851,7 +851,7 @@ export default class Root extends Route {
|
|||
const page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
|
||||
const skipped = page || page * 10;
|
||||
|
||||
const eo = await this.server.client.db.ExecutiveOrder.find().skip(skipped);
|
||||
const eo = await this.server.client.db.mongo.ExecutiveOrder.find().skip(skipped);
|
||||
const returned: {
|
||||
oID: string;
|
||||
author: string;
|
||||
|
@ -879,7 +879,7 @@ export default class Root extends Route {
|
|||
const page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
|
||||
const skipped = page || page * 10;
|
||||
|
||||
const motion = await this.server.client.db.Motion.find().skip(skipped);
|
||||
const motion = await this.server.client.db.mongo.Motion.find().skip(skipped);
|
||||
const returned: {
|
||||
oID: string;
|
||||
author: string;
|
||||
|
@ -907,7 +907,7 @@ export default class Root extends Route {
|
|||
const page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
|
||||
const skipped = page || page * 10;
|
||||
|
||||
const proc = await this.server.client.db.Proclamation.find().skip(skipped);
|
||||
const proc = await this.server.client.db.mongo.Proclamation.find().skip(skipped);
|
||||
const returned: {
|
||||
oID: string;
|
||||
author: string;
|
||||
|
@ -935,7 +935,7 @@ export default class Root extends Route {
|
|||
const page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
|
||||
const skipped = page || page * 10;
|
||||
|
||||
const resolution = await this.server.client.db.Resolution.find().skip(skipped);
|
||||
const resolution = await this.server.client.db.mongo.Resolution.find().skip(skipped);
|
||||
const returned: {
|
||||
oID: string;
|
||||
author: string;
|
||||
|
@ -968,7 +968,7 @@ 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.mongo.Motion.findOne({ oID: req.params.id });
|
||||
|
||||
if (!motion) {
|
||||
return res.status(404).json({
|
||||
|
@ -1032,7 +1032,7 @@ export default class Root extends Route {
|
|||
const resolutionMessage = await this.brsVotingChannel.createMessage({ embed: resolutionEmbed });
|
||||
const resolutionID = genUUID();
|
||||
|
||||
await this.server.client.db.Resolution.create({
|
||||
await this.server.client.db.mongo.Resolution.create({
|
||||
issuer: motion.issuer,
|
||||
subject: motion.subject,
|
||||
body: motion.body,
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
export { default as internal } from './internal';
|
||||
export { default as keys } from './keys';
|
||||
export { default as report } from './report';
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import axios, { AxiosResponse } from 'axios';
|
||||
import { Route, Server } from '../../../class';
|
||||
|
||||
import { X509Certificate } from '../../../commands/x509';
|
||||
import { PGPKey, PublicKeyAlgorithm } from '../../../commands/pgp';
|
||||
|
||||
export default class Internal extends Route {
|
||||
constructor(server: Server) {
|
||||
super(server);
|
||||
this.conf = {
|
||||
path: '/internal',
|
||||
};
|
||||
}
|
||||
|
||||
public bind() {
|
||||
this.router.all('*', (_req, res, next) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', '*');
|
||||
res.setHeader('Access-Control-Allow-Headers', '*');
|
||||
next();
|
||||
});
|
||||
|
||||
this.router.get('/check-cwg-self-auth', async (req, res) => {
|
||||
if (req.query.internalKey !== this.server.client.config.internalKey) return res.sendStatus(401);
|
||||
|
||||
const member = await this.server.client.guilds.get(this.server.client.config.guildID).getRESTMember(req.query.userID.toString());
|
||||
if (!member) return res.sendStatus(404);
|
||||
|
||||
const tokenC = await this.server.client.db.redis.get(req.query.token.toString());
|
||||
if (!tokenC) return res.sendStatus(404);
|
||||
|
||||
if (tokenC !== member.id) return res.sendStatus(403);
|
||||
|
||||
await this.server.client.db.redis.del(req.query.token.toString());
|
||||
|
||||
return res.sendStatus(204);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ export default class Keys extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/p/:type/x509/:userID', async (req, res) => {
|
||||
const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const memberDoc = await this.server.client.db.mongo.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const member = this.mainGuild.members.get(req.params.userID);
|
||||
if (!member || !memberDoc || !memberDoc?.x509) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
if (req.params.type === 'download') res.contentType('application/x-x509-user-cert');
|
||||
|
@ -29,7 +29,7 @@ export default class Keys extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/p/:type/pgp/:userID', async (req, res) => {
|
||||
const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const memberDoc = await this.server.client.db.mongo.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const member = this.mainGuild.members.get(req.params.userID);
|
||||
if (!member || !memberDoc || !memberDoc?.pgp) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
if (req.params.type === 'download') res.contentType('application/pgp-keys');
|
||||
|
@ -41,7 +41,7 @@ export default class Keys extends Route {
|
|||
// })
|
||||
|
||||
this.router.get('/~/x509/:userID', async (req, res) => {
|
||||
const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const memberDoc = await this.server.client.db.mongo.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const member = this.mainGuild.members.get(req.params.userID);
|
||||
if (!member || !memberDoc || !memberDoc?.x509) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
|
||||
|
@ -76,7 +76,7 @@ export default class Keys extends Route {
|
|||
});
|
||||
|
||||
this.router.get('/~/pgp/:userID', async (req, res) => {
|
||||
const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const memberDoc = await this.server.client.db.mongo.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const member = this.mainGuild.members.get(req.params.userID);
|
||||
if (!member || !memberDoc || !memberDoc?.pgp) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
/* eslint-disable no-continue */
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { TextChannel } from 'eris';
|
||||
import { ScoreHistorical } from 'cr-db/mongodb';
|
||||
import { LocalStorage, Route, Server } from '../../../class';
|
||||
import { ScoreHistoricalInterface, ScoreHistoricalRaw } from '../../../models/ScoreHistorical';
|
||||
import { getTotalMessageCount } from '../../../intervals/score';
|
||||
|
||||
export default class Report extends Route {
|
||||
|
@ -53,10 +53,10 @@ export default class Report extends Route {
|
|||
if (!req.body.pin || !req.body.userID || !req.body.reason) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR });
|
||||
if (req.body.reason?.length < 1) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const merchant = await this.server.client.db.Merchant.findOne({ key: req.headers.authorization }).lean().exec();
|
||||
const merchant = await this.server.client.db.mongo.Merchant.findOne({ key: req.headers.authorization }).lean().exec();
|
||||
if (!merchant) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
||||
const member = await this.server.client.db.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
|
||||
const member = await this.server.client.db.mongo.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
|
||||
if (!member) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
||||
const mem = this.server.client.util.resolveMember(member.userID, this.server.client.guilds.get(this.server.client.config.guildID));
|
||||
|
@ -66,7 +66,7 @@ export default class Report extends Route {
|
|||
if (merchant?.type !== 1) return res.status(403).json({ code: this.constants.codes.PERMISSION_DENIED, message: this.constants.messages.PERMISSION_DENIED });
|
||||
|
||||
if (this.check(member.userID)) {
|
||||
await this.server.client.db.Score.updateOne({ userID: member.userID }, { $set: { locked: true } });
|
||||
await this.server.client.db.mongo.Score.updateOne({ userID: member.userID }, { $set: { locked: true } });
|
||||
const chan = await this.server.client.getDMChannel(member.userID);
|
||||
try {
|
||||
await chan.createMessage(`__**Community Report Locked**__\nWe've detected suspicious activity on your Community Report, for the integrity of your report we have automatically locked it. To unlock your report, please run \`${this.server.client.config.prefix}score pref unlock\` in <#468759629334183956>.`);
|
||||
|
@ -93,7 +93,7 @@ export default class Report extends Route {
|
|||
if ((mem.user.publicFlags & (1 << 17)) === 1 << 17) flags.push('EARLY_VERIFIED_BOT_DEVELOPER');
|
||||
}
|
||||
const set = [];
|
||||
const accounts = await this.server.client.db.Score.find().lean().exec();
|
||||
const accounts = await this.server.client.db.mongo.Score.find().lean().exec();
|
||||
for (const sc of accounts) {
|
||||
if (sc.total < 200) { continue; }
|
||||
if (sc.total > 800) { set.push(800); continue; }
|
||||
|
@ -127,7 +127,7 @@ export default class Report extends Route {
|
|||
else if (member.cloudServices > 10) cloudServicesScore = 10;
|
||||
else cloudServicesScore = Math.round(member.cloudServices);
|
||||
|
||||
const inqs = await this.server.client.db.Inquiry.find({ userID: member.userID }).lean().exec();
|
||||
const inqs = await this.server.client.db.mongo.Inquiry.find({ userID: member.userID }).lean().exec();
|
||||
const inquiries: [{ id?: string, name: string, date: Date }?] = [];
|
||||
if (inqs?.length > 0) {
|
||||
for (const inq of inqs) {
|
||||
|
@ -136,10 +136,10 @@ export default class Report extends Route {
|
|||
}
|
||||
}
|
||||
|
||||
const judgements = await this.server.client.db.Judgement.find({ userID: member.userID }).lean().exec();
|
||||
const judgements = await this.server.client.db.mongo.Judgement.find({ userID: member.userID }).lean().exec();
|
||||
|
||||
const historicalData = await this.server.client.db.ScoreHistorical.find({ userID: member.userID }).lean().exec();
|
||||
const array: ScoreHistoricalRaw[] = [];
|
||||
const historicalData = await this.server.client.db.mongo.ScoreHistorical.find({ userID: member.userID }).lean().exec();
|
||||
const array: ScoreHistorical[] = [];
|
||||
for (const data of historicalData) {
|
||||
let total: number;
|
||||
let activity: number;
|
||||
|
@ -175,7 +175,7 @@ export default class Report extends Route {
|
|||
|
||||
const inq = await this.server.client.report.createInquiry(member.userID, merchant.name, 0, req.body.reason);
|
||||
|
||||
await this.server.client.db.Merchant.updateOne({ key: req.headers.authorization }, { $addToSet: { pulls: { type: 0, reason: req.body.reason, date: new Date() } } });
|
||||
await this.server.client.db.mongo.Merchant.updateOne({ key: req.headers.authorization }, { $addToSet: { pulls: { type: 0, reason: req.body.reason, date: new Date() } } });
|
||||
|
||||
return res.status(200).json({
|
||||
code: this.constants.codes.SUCCESS,
|
||||
|
@ -214,10 +214,10 @@ export default class Report extends Route {
|
|||
if (!req.headers.authorization) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.body.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR });
|
||||
|
||||
const merchant = await this.server.client.db.Merchant.findOne({ key: req.headers.authorization }).lean().exec();
|
||||
const merchant = await this.server.client.db.mongo.Merchant.findOne({ key: req.headers.authorization }).lean().exec();
|
||||
if (!merchant) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
||||
const report = await this.server.client.db.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
|
||||
const report = await this.server.client.db.mongo.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
|
||||
if (!report) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
||||
let totalScore: number;
|
||||
|
@ -226,7 +226,7 @@ export default class Report extends Route {
|
|||
else if (report.total > 800) totalScore = 800;
|
||||
else totalScore = Math.round(report.total);
|
||||
|
||||
await this.server.client.db.Merchant.updateOne({ key: req.headers.authorization }, { $addToSet: { pulls: { type: 1, reason: 'N/A', date: new Date() } } });
|
||||
await this.server.client.db.mongo.Merchant.updateOne({ key: req.headers.authorization }, { $addToSet: { pulls: { type: 1, reason: 'N/A', date: new Date() } } });
|
||||
const mem = this.server.client.util.resolveMember(report.userID, this.server.client.guilds.get(this.server.client.config.guildID));
|
||||
await this.server.client.report.createInquiry(report.userID, merchant.name.toUpperCase(), 1);
|
||||
|
||||
|
@ -257,7 +257,7 @@ export default class Report extends Route {
|
|||
}
|
||||
const set = [];
|
||||
if (req.query.p?.toString() === 'true') {
|
||||
const accounts = await this.server.client.db.Score.find().lean().exec();
|
||||
const accounts = await this.server.client.db.mongo.Score.find().lean().exec();
|
||||
for (const sc of accounts) {
|
||||
if (sc.total < 200) { continue; }
|
||||
if (sc.total > 800) { set.push(800); continue; }
|
||||
|
@ -265,7 +265,7 @@ export default class Report extends Route {
|
|||
}
|
||||
}
|
||||
|
||||
const judgements = await this.server.client.db.Judgement.find({ userID: report.userID }).lean().exec();
|
||||
const judgements = await this.server.client.db.mongo.Judgement.find({ userID: report.userID }).lean().exec();
|
||||
|
||||
let activityScore: number;
|
||||
const moderationScore = Math.round(report.moderation);
|
||||
|
@ -289,8 +289,8 @@ export default class Report extends Route {
|
|||
else if (report.cloudServices > 10) cloudServicesScore = 10;
|
||||
else cloudServicesScore = Math.round(report.cloudServices);
|
||||
|
||||
const historicalData = await this.server.client.db.ScoreHistorical.find({ userID: report.userID }).lean().exec();
|
||||
const array: ScoreHistoricalRaw[] = [];
|
||||
const historicalData = await this.server.client.db.mongo.ScoreHistorical.find({ userID: report.userID }).lean().exec();
|
||||
const array: ScoreHistorical[] = [];
|
||||
for (const data of historicalData) {
|
||||
let total: number;
|
||||
let activity: number;
|
||||
|
@ -359,10 +359,10 @@ export default class Report extends Route {
|
|||
if (!req.headers.authorization) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.body.pin || !req.body.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR });
|
||||
|
||||
const merchant = await this.server.client.db.Merchant.findOne({ key: req.headers.authorization }).lean().exec();
|
||||
const merchant = await this.server.client.db.mongo.Merchant.findOne({ key: req.headers.authorization }).lean().exec();
|
||||
if (!merchant) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
||||
const member = await this.server.client.db.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
|
||||
const member = await this.server.client.db.mongo.Score.findOne({ userID: req.body.userID, 'pin.2': req.body.pin }).lean().exec();
|
||||
if (!member) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
const mem = this.server.client.util.resolveMember(member.userID, this.server.client.guilds.get(this.server.client.config.guildID));
|
||||
if (!mem) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.codes.NOT_FOUND });
|
||||
|
@ -373,7 +373,7 @@ export default class Report extends Route {
|
|||
else if (member.total > 800) totalScore = 800;
|
||||
else totalScore = Math.round(member.total);
|
||||
|
||||
await this.server.client.db.Merchant.updateOne({ key: req.headers.authorization }, { $addToSet: { pulls: { type: 1, reason: 'N/A', date: new Date() } } });
|
||||
await this.server.client.db.mongo.Merchant.updateOne({ key: req.headers.authorization }, { $addToSet: { pulls: { type: 1, reason: 'N/A', date: new Date() } } });
|
||||
await this.server.client.report.createInquiry(member.userID, merchant.name.toUpperCase(), 1);
|
||||
|
||||
if (!merchant.privileged) {
|
||||
|
@ -433,7 +433,7 @@ export default class Report extends Route {
|
|||
const args = req.query.pin.toString();
|
||||
this.timeout.set(req.ip, 1);
|
||||
setTimeout(() => this.timeout.delete(req.ip), 1800000);
|
||||
let score = await this.server.client.db.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
let score = await this.server.client.db.mongo.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
if (!score) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
const member = await this.server.client.getRESTGuildMember(this.constants.discord.SERVER_ID, score.userID);
|
||||
if (!member) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
@ -441,7 +441,7 @@ export default class Report extends Route {
|
|||
if (req.query.staff) {
|
||||
// eslint-disable-next-line no-shadow
|
||||
const args = req.query.staff.toString();
|
||||
const staffScore = await this.server.client.db.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
const staffScore = await this.server.client.db.mongo.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
if (!staffScore) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!staffScore.staff) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
this.timeout.delete(req.ip);
|
||||
|
@ -454,7 +454,7 @@ export default class Report extends Route {
|
|||
} else if (!updated) {
|
||||
await this.server.client.report.createInquiry(member.user.id, `${member.username} via report.libraryofcode.org @ IP ${req.ip}`, 1);
|
||||
}
|
||||
score = await this.server.client.db.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
score = await this.server.client.db.mongo.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
|
||||
let totalScore = '0';
|
||||
let activityScore = '0';
|
||||
|
@ -488,9 +488,9 @@ export default class Report extends Route {
|
|||
else if (score.cloudServices > 10) cloudServicesScore = '10';
|
||||
else cloudServicesScore = `${score.cloudServices}`;
|
||||
|
||||
const moderations = await this.server.client.db.Moderation.find({ userID: score.userID }).lean().exec();
|
||||
const moderations = await this.server.client.db.mongo.Moderation.find({ userID: score.userID }).lean().exec();
|
||||
|
||||
const historical = await this.server.client.db.ScoreHistorical.find({ userID: score.userID }).lean().exec();
|
||||
const historical = await this.server.client.db.mongo.ScoreHistorical.find({ userID: score.userID }).lean().exec();
|
||||
|
||||
for (const data of historical) {
|
||||
let total: number;
|
||||
|
@ -523,7 +523,7 @@ export default class Report extends Route {
|
|||
data.report.total = total; data.report.activity = activity; data.report.moderation = moderation; data.report.roles = role; data.report.cloudServices = cloud; data.report.other = other; data.report.staff = misc;
|
||||
}
|
||||
|
||||
const inqs = await this.server.client.db.Inquiry.find({ userID: score.userID }).lean().exec();
|
||||
const inqs = await this.server.client.db.mongo.Inquiry.find({ userID: score.userID }).lean().exec();
|
||||
const hardInquiries: [{ id?: string, name: string, reason: string, date: Date }?] = [];
|
||||
const softInquiries: [{ id?: string, name: string, date: Date }?] = [];
|
||||
for (const inq of inqs) {
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class Root extends Route {
|
|||
this.router.get('/m/:id', async (req, res) => {
|
||||
try {
|
||||
const id = req.params.id.split('.')[0];
|
||||
const file = await this.server.client.db.File.findOne({ identifier: id });
|
||||
const file = await this.server.client.db.mongo.File.findOne({ identifier: id });
|
||||
if (!file) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
if (file.downloaded >= file.maxDownloads) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
if (req.query.d === '1') {
|
||||
|
|
|
@ -25,12 +25,12 @@ export default class Internal extends Route {
|
|||
let member = this.server.client.guilds.get(this.server.client.config.guildID).members.get(req.query.id.toString());
|
||||
if (!member) member = await this.server.client.getRESTGuildMember(this.server.client.config.guildID, req.query.id.toString());
|
||||
if (!member) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
const pagerNumber = await this.server.client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
|
||||
const pagerNumber = await this.server.client.db.mongo.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
|
||||
let status = false;
|
||||
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) status = true;
|
||||
return res.status(200).json({ staff: status, username: member.user.username, discriminator: member.user.discriminator, nick: member.nick, avatarURL: member.user.avatarURL, pager: pagerNumber?.num });
|
||||
}
|
||||
const acknowledgements = await this.server.client.db.Staff.find().lean().exec();
|
||||
const acknowledgements = await this.server.client.db.mongo.Staff.find().lean().exec();
|
||||
return res.status(200).json(acknowledgements);
|
||||
} catch (err) {
|
||||
return this.handleError(err, res);
|
||||
|
@ -58,7 +58,7 @@ export default class Internal extends Route {
|
|||
if (req.query?.auth?.toString() !== this.server.client.config.internalKey) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query.pin) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
const args = req.query.pin.toString();
|
||||
const user = await this.server.client.db.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
const user = await this.server.client.db.mongo.Score.findOne({ pin: [Number(args.split('-')[0]), Number(args.split('-')[1]), Number(args.split('-')[2])] }).lean().exec();
|
||||
if (!user) return res.status(404).json({ code: this.constants.codes.ACCOUNT_NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
return res.status(200).json({ userID: user.userID });
|
||||
} catch (err) {
|
||||
|
@ -71,7 +71,7 @@ export default class Internal extends Route {
|
|||
if (req.query?.auth?.toString() !== this.server.client.config.internalKey) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query.id) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const report = await this.server.client.db.Score.findOne({ userID: req.query.id.toString() });
|
||||
const report = await this.server.client.db.mongo.Score.findOne({ userID: req.query.id.toString() });
|
||||
if (!report) return res.status(404).json({ code: this.constants.codes.ACCOUNT_NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
return res.status(200).json({ pin: report.pin });
|
||||
} catch (err) {
|
||||
|
@ -89,7 +89,7 @@ export default class Internal extends Route {
|
|||
return res.sendStatus(400);
|
||||
case 'customer.subscription.created':
|
||||
if (data.items.data[0].price.product === 'prod_Hi4EYmf2am5VZt') {
|
||||
const customer = await this.server.client.db.Customer.findOne({ cusID: data.customer }).lean().exec();
|
||||
const customer = await this.server.client.db.mongo.Customer.findOne({ cusID: data.customer }).lean().exec();
|
||||
if (!customer) return res.sendStatus(404);
|
||||
await axios({
|
||||
method: 'get',
|
||||
|
@ -100,7 +100,7 @@ export default class Internal extends Route {
|
|||
break;
|
||||
case 'customer.subscription.deleted':
|
||||
if (data.items.data[0].price.product === 'prod_Hi4EYmf2am5VZt') {
|
||||
const customer = await this.server.client.db.Customer.findOne({ cusID: data.customer }).lean().exec();
|
||||
const customer = await this.server.client.db.mongo.Customer.findOne({ cusID: data.customer }).lean().exec();
|
||||
if (!customer) return res.sendStatus(404);
|
||||
await axios({
|
||||
method: 'get',
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Route, Server } from '../../../class';
|
||||
import { RedirectRaw } from '../../../models';
|
||||
|
||||
export default class Root extends Route {
|
||||
constructor(server: Server) {
|
||||
|
@ -14,11 +13,11 @@ export default class Root extends Route {
|
|||
|
||||
this.router.get('/dash', async (req, res) => {
|
||||
try {
|
||||
const lookup = await this.server.client.db.CustomerPortal.findOne({ key: req.query.q?.toString() });
|
||||
const lookup = await this.server.client.db.mongo.CustomerPortal.findOne({ key: req.query.q?.toString() });
|
||||
if (!lookup) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
if (new Date(lookup.expiresOn) < new Date()) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
|
||||
const customer = await this.server.client.db.Customer.findOne({ userID: lookup.userID });
|
||||
const customer = await this.server.client.db.mongo.Customer.findOne({ userID: lookup.userID });
|
||||
if (!customer) {
|
||||
const newCus = await this.server.client.stripe.customers.create({
|
||||
email: lookup.emailAddress,
|
||||
|
@ -27,7 +26,7 @@ export default class Root extends Route {
|
|||
username: lookup.username,
|
||||
},
|
||||
});
|
||||
await (new this.server.client.db.Customer({
|
||||
await (new this.server.client.db.mongo.Customer({
|
||||
cusID: newCus.id,
|
||||
userID: lookup.userID,
|
||||
})).save();
|
||||
|
@ -51,10 +50,10 @@ export default class Root extends Route {
|
|||
|
||||
this.router.get('/:key', async (req, res) => {
|
||||
try {
|
||||
const link: RedirectRaw = await this.server.client.db.Redirect.findOne({ key: req.params.key }).lean().exec();
|
||||
const link = await this.server.client.db.mongo.Redirect.findOne({ key: req.params.key }).lean();
|
||||
if (!link) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
res.redirect(link.to);
|
||||
return await this.server.client.db.Redirect.updateOne({ key: req.params.key }, { $inc: { visitedCount: 1 } });
|
||||
return await this.server.client.db.mongo.Redirect.updateOne({ key: req.params.key }, { $inc: { visitedCount: 1 } });
|
||||
} catch (err) {
|
||||
this.server.client.util.handleError(err);
|
||||
return res.status(500).json({ code: this.constants.codes.SERVER_ERROR, message: this.constants.messages.SERVER_ERROR });
|
||||
|
|
|
@ -1,35 +1,14 @@
|
|||
import Stripe from 'stripe';
|
||||
import Redis from 'ioredis';
|
||||
import eris from 'eris';
|
||||
import pluris from 'pluris';
|
||||
import mongoose from 'mongoose';
|
||||
import { promises as fs } from 'fs';
|
||||
import Database from 'cr-db';
|
||||
import { Collection, Command, InteractionCommand, LocalStorage, Queue, Util, ServerManagement, Event } from '.';
|
||||
import {
|
||||
Customer, CustomerInterface,
|
||||
CustomerPortal, CustomerPortalInterface,
|
||||
ExecutiveOrder, ExecutiveOrderInterface,
|
||||
File, FileInterface,
|
||||
Inquiry, InquiryInterface,
|
||||
Judgement, JudgementInterface,
|
||||
Member, MemberInterface,
|
||||
Merchant, MerchantInterface,
|
||||
Moderation, ModerationInterface,
|
||||
Motion, MotionInterface,
|
||||
Note, NoteInterface,
|
||||
PagerNumber, PagerNumberInterface,
|
||||
Proclamation, ProclamationInterface,
|
||||
Promo, PromoInterface,
|
||||
Rank, RankInterface,
|
||||
Redirect, RedirectInterface,
|
||||
Resolution, ResolutionInterface,
|
||||
SAA, SAAInterface,
|
||||
Score, ScoreInterface,
|
||||
ScoreHistorical, ScoreHistoricalInterface,
|
||||
Staff, StaffInterface,
|
||||
Stat, StatInterface,
|
||||
} from '../models';
|
||||
import { Config } from '../../types'; // eslint-disable-line
|
||||
|
||||
// @ts-ignore
|
||||
pluris(eris, { endpoints: false });
|
||||
|
||||
export default class Client extends eris.Client {
|
||||
|
@ -52,32 +31,11 @@ export default class Client extends eris.Client {
|
|||
|
||||
public stripe: Stripe;
|
||||
|
||||
|
||||
|
||||
public db: {
|
||||
Customer: mongoose.Model<CustomerInterface>,
|
||||
CustomerPortal: mongoose.Model<CustomerPortalInterface>,
|
||||
ExecutiveOrder: mongoose.Model<ExecutiveOrderInterface>,
|
||||
File: mongoose.Model<FileInterface>,
|
||||
Inquiry: mongoose.Model<InquiryInterface>,
|
||||
Judgement: mongoose.Model<JudgementInterface>,
|
||||
Member: mongoose.Model<MemberInterface>,
|
||||
Merchant: mongoose.Model<MerchantInterface>,
|
||||
Moderation: mongoose.Model<ModerationInterface>,
|
||||
Motion: mongoose.Model<MotionInterface>,
|
||||
Note: mongoose.Model<NoteInterface>,
|
||||
PagerNumber: mongoose.Model<PagerNumberInterface>,
|
||||
Proclamation: mongoose.Model<ProclamationInterface>,
|
||||
Promo: mongoose.Model<PromoInterface>,
|
||||
Rank: mongoose.Model<RankInterface>,
|
||||
Redirect: mongoose.Model<RedirectInterface>,
|
||||
Resolution: mongoose.Model<ResolutionInterface>,
|
||||
SAA: mongoose.Model<SAAInterface>,
|
||||
Score: mongoose.Model<ScoreInterface>,
|
||||
ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>,
|
||||
Staff: mongoose.Model<StaffInterface>,
|
||||
Stat: mongoose.Model<StatInterface>,
|
||||
local: { muted: LocalStorage }
|
||||
mongo: typeof Database.MongoDBModels,
|
||||
maria: null,
|
||||
redis: Redis.Redis,
|
||||
local: { muted: LocalStorage },
|
||||
};
|
||||
|
||||
constructor(token: string, options?: eris.ClientOptions) {
|
||||
|
@ -89,29 +47,12 @@ export default class Client extends eris.Client {
|
|||
this.intervals = new Collection<NodeJS.Timeout>();
|
||||
this.queue = new Queue(this);
|
||||
this.db = {
|
||||
Customer,
|
||||
CustomerPortal,
|
||||
ExecutiveOrder,
|
||||
File,
|
||||
Inquiry,
|
||||
Judgement,
|
||||
Member,
|
||||
Merchant,
|
||||
Moderation,
|
||||
Motion,
|
||||
Note,
|
||||
PagerNumber,
|
||||
Promo,
|
||||
Proclamation,
|
||||
Rank,
|
||||
Redirect,
|
||||
Resolution,
|
||||
SAA,
|
||||
Score,
|
||||
ScoreHistorical,
|
||||
Staff,
|
||||
Stat,
|
||||
local: { muted: new LocalStorage('muted') },
|
||||
mongo: Database.MongoDBModels,
|
||||
redis: new Redis(),
|
||||
local: {
|
||||
muted: new LocalStorage('muted'),
|
||||
},
|
||||
maria: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -129,22 +70,22 @@ export default class Client extends eris.Client {
|
|||
minPoolSize: 50,
|
||||
});
|
||||
|
||||
const statMessages = await this.db.Stat.findOne({ name: 'messages' });
|
||||
const statCommands = await this.db.Stat.findOne({ name: 'commands' });
|
||||
const statPages = await this.db.Stat.findOne({ name: 'pages' });
|
||||
const statRequests = await this.db.Stat.findOne({ name: 'requests' });
|
||||
const statMessages = await this.db.mongo.Stat.findOne({ name: 'messages' });
|
||||
const statCommands = await this.db.mongo.Stat.findOne({ name: 'commands' });
|
||||
const statPages = await this.db.mongo.Stat.findOne({ name: 'pages' });
|
||||
const statRequests = await this.db.mongo.Stat.findOne({ name: 'requests' });
|
||||
|
||||
if (!statMessages) {
|
||||
await (new this.db.Stat({ name: 'messages', value: 0 }).save());
|
||||
await (new this.db.mongo.Stat({ name: 'messages', value: 0 }).save());
|
||||
}
|
||||
if (!statCommands) {
|
||||
await (new this.db.Stat({ name: 'commands', value: 0 }).save());
|
||||
await (new this.db.mongo.Stat({ name: 'commands', value: 0 }).save());
|
||||
}
|
||||
if (!statPages) {
|
||||
await (new this.db.Stat({ name: 'pages', value: 0 }).save());
|
||||
await (new this.db.mongo.Stat({ name: 'pages', value: 0 }).save());
|
||||
}
|
||||
if (!statRequests) {
|
||||
await (new this.db.Stat({ name: 'requests', value: 0 }).save());
|
||||
await (new this.db.mongo.Stat({ name: 'requests', value: 0 }).save());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { Member, User } from 'eris';
|
|||
import { randomBytes } from 'crypto';
|
||||
import moment, { unitOfTime } from 'moment';
|
||||
import { Client, RichEmbed } from '.';
|
||||
import { Moderation as ModerationModel, ModerationInterface } from '../models';
|
||||
import { moderation as channels } from '../configs/channels.json';
|
||||
|
||||
export default class Moderation {
|
||||
|
@ -40,11 +39,11 @@ export default class Moderation {
|
|||
return moment.duration(length, unit).asMilliseconds();
|
||||
}
|
||||
|
||||
public async ban(user: User, moderator: Member, duration: number, reason?: string): Promise<ModerationInterface> {
|
||||
public async ban(user: User, moderator: Member, duration: number, reason?: string) {
|
||||
if (reason && reason.length > 512) throw new Error('Ban reason cannot be longer than 512 characters');
|
||||
await this.client.guilds.get(this.client.config.guildID).banMember(user.id, 7, reason);
|
||||
const logID = randomBytes(2).toString('hex');
|
||||
const mod = new ModerationModel({
|
||||
const mod = new this.client.db.mongo.Moderation({
|
||||
userID: user.id,
|
||||
logID,
|
||||
moderatorID: moderator.id,
|
||||
|
@ -81,12 +80,12 @@ export default class Moderation {
|
|||
return mod.save();
|
||||
}
|
||||
|
||||
public async unban(userID: string, moderator: Member, reason?: string): Promise<ModerationInterface> {
|
||||
public async unban(userID: string, moderator: Member, reason?: string) {
|
||||
this.client.unbanGuildMember(this.client.config.guildID, userID, reason);
|
||||
const user = await this.client.getRESTUser(userID);
|
||||
if (!user) throw new Error('Cannot get user.');
|
||||
const logID = randomBytes(2).toString('hex');
|
||||
const mod = new ModerationModel({
|
||||
const mod = new this.client.db.mongo.Moderation({
|
||||
userID,
|
||||
logID,
|
||||
moderatorID: moderator.id,
|
||||
|
@ -111,13 +110,13 @@ export default class Moderation {
|
|||
return mod.save();
|
||||
}
|
||||
|
||||
public async mute(user: User, moderator: Member, duration: number, reason?: string): Promise<ModerationInterface> {
|
||||
public async mute(user: User, moderator: Member, duration: number, reason?: string) {
|
||||
if (reason && reason.length > 512) throw new Error('Mute reason cannot be longer than 512 characters');
|
||||
const member = await this.client.getRESTGuildMember(this.client.config.guildID, user.id);
|
||||
if (!member) throw new Error('Cannot find member.');
|
||||
await member.addRole('478373942638149643', `Muted by ${moderator.username}#${moderator.discriminator}`);
|
||||
const logID = randomBytes(2).toString('hex');
|
||||
const mod = new ModerationModel({
|
||||
const mod = new this.client.db.mongo.Moderation({
|
||||
userID: user.id,
|
||||
logID,
|
||||
moderatorID: moderator.id,
|
||||
|
@ -155,14 +154,14 @@ export default class Moderation {
|
|||
return mod.save();
|
||||
}
|
||||
|
||||
public async unmute(userID: string, moderator: Member, reason?: string): Promise<ModerationInterface> {
|
||||
public async unmute(userID: string, moderator: Member, reason?: string) {
|
||||
const member = await this.client.getRESTGuildMember(this.client.config.guildID, userID);
|
||||
const user = await this.client.getRESTUser(userID);
|
||||
if (member) {
|
||||
await member.removeRole('478373942638149643');
|
||||
}
|
||||
const logID = randomBytes(2).toString('hex');
|
||||
const mod = new ModerationModel({
|
||||
const mod = new this.client.db.mongo.Moderation({
|
||||
userID,
|
||||
logID,
|
||||
moderatorID: moderator.id,
|
||||
|
@ -189,11 +188,11 @@ export default class Moderation {
|
|||
return mod.save();
|
||||
}
|
||||
|
||||
public async kick(user: Member | User, moderator: Member, reason?: string): Promise<ModerationInterface> {
|
||||
public async kick(user: Member | User, moderator: Member, reason?: string) {
|
||||
if (reason && reason.length > 512) throw new Error('Kick reason cannot be longer than 512 characters');
|
||||
await this.client.guilds.get(this.client.config.guildID).kickMember(user.id, reason);
|
||||
const logID = randomBytes(2).toString('hex');
|
||||
const mod = new ModerationModel({
|
||||
const mod = new this.client.db.mongo.Moderation({
|
||||
userID: user.id,
|
||||
logID,
|
||||
moderatorID: moderator.id,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
/* eslint-disable no-eval */
|
||||
import Bull from 'bull';
|
||||
import { InqType, Score } from 'cr-db/mongodb';
|
||||
import cron from 'cron';
|
||||
import { TextableChannel, TextChannel } from 'eris';
|
||||
import { Client, RichEmbed } from '.';
|
||||
import { ScoreInterface, InqType as InquiryType } from '../models';
|
||||
|
||||
import { apply as Apply } from '../commands';
|
||||
|
||||
|
@ -25,12 +25,12 @@ export default class Queue {
|
|||
protected setCronJobs() {
|
||||
const historialCommunityReportJob = new cron.CronJob('0 20 * * *', async () => {
|
||||
try {
|
||||
const reports = await this.client.db.Score.find().lean().exec();
|
||||
const reports = await this.client.db.mongo.Score.find().lean().exec();
|
||||
const startDate = new Date();
|
||||
|
||||
for (const report of reports) {
|
||||
const inqs = await this.client.db.Inquiry.find({ userID: report.userID });
|
||||
const data = new this.client.db.ScoreHistorical({
|
||||
const inqs = await this.client.db.mongo.Inquiry.find({ userID: report.userID });
|
||||
const data = new this.client.db.mongo.ScoreHistorical({
|
||||
userID: report.userID,
|
||||
report: {
|
||||
total: report.total,
|
||||
|
@ -52,7 +52,7 @@ export default class Queue {
|
|||
});
|
||||
|
||||
const clearOldHistoricalReportsJob = new cron.CronJob('0 22 * * *', async () => {
|
||||
this.client.db.ScoreHistorical.remove({ date: { $lt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) } });
|
||||
this.client.db.mongo.ScoreHistorical.remove({ date: { $lt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) } });
|
||||
});
|
||||
|
||||
historialCommunityReportJob.start();
|
||||
|
@ -92,11 +92,11 @@ export default class Queue {
|
|||
}
|
||||
|
||||
protected setProcessors() {
|
||||
this.queues.score.process('score::inquiry', async (job: Bull.Job<{ inqID: string, userID: string, name: string, type: InquiryType, reason?: string }>) => {
|
||||
this.queues.score.process('score::inquiry', async (job: Bull.Job<{ inqID: string, userID: string, name: string, type: InqType, reason?: string }>) => {
|
||||
const member = this.client.util.resolveMember(job.data.userID, this.client.guilds.get(this.client.config.guildID));
|
||||
const report = await this.client.db.Score.findOne({ userID: job.data.userID }).lean().exec();
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID: job.data.userID }).lean().exec();
|
||||
const embed = new RichEmbed();
|
||||
if (job.data.type === InquiryType.HARD) {
|
||||
if (job.data.type === InqType.Hard) {
|
||||
embed.setTitle('Inquiry Notification');
|
||||
embed.setDescription(job.data.inqID);
|
||||
embed.setColor('#800080');
|
||||
|
@ -123,10 +123,10 @@ export default class Queue {
|
|||
const log = <TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('611584771356622849');
|
||||
log.createMessage({ embed }).catch(() => {});
|
||||
});
|
||||
this.queues.score.process('score::update', async (job: Bull.Job<{ score: ScoreInterface, total: number, activity: number, roles: number, moderation: number, cloudServices: number, other: number, staff: number }>) => {
|
||||
await this.client.db.Score.updateOne({ userID: job.data.score.userID }, { $set: { total: job.data.total, activity: job.data.activity, roles: job.data.roles, moderation: job.data.moderation, cloudServices: job.data.cloudServices, other: job.data.other, staff: job.data.staff, lastUpdate: new Date() } });
|
||||
this.queues.score.process('score::update', async (job: Bull.Job<{ score: Score, total: number, activity: number, roles: number, moderation: number, cloudServices: number, other: number, staff: number }>) => {
|
||||
await this.client.db.mongo.Score.updateOne({ userID: job.data.score.userID }, { $set: { total: job.data.total, activity: job.data.activity, roles: job.data.roles, moderation: job.data.moderation, cloudServices: job.data.cloudServices, other: job.data.other, staff: job.data.staff, lastUpdate: new Date() } });
|
||||
if (!job.data.score.pin || job.data.score.pin?.length < 1) {
|
||||
await this.client.db.Score.updateOne({ userID: job.data.score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } });
|
||||
await this.client.db.mongo.Score.updateOne({ userID: job.data.score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } });
|
||||
}
|
||||
});
|
||||
this.queues.score.process('score::apply', async (job: Bull.Job<{ channelInformation: { messageID: string, guildID: string, channelID: string }, url: string, userID: string, func?: string }>) => {
|
||||
|
@ -179,14 +179,14 @@ export default class Queue {
|
|||
});
|
||||
}
|
||||
|
||||
public addInquiry(inqID: string, userID: string, name: string, type: InquiryType, reason?: string) {
|
||||
public addInquiry(inqID: string, userID: string, name: string, type: InqType, reason?: string) {
|
||||
return this.queues.score.add('score::inquiry', { inqID, userID, name, type, reason });
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public updateScore(score: ScoreInterface, total: number, activity: number, roles: number, moderation: number, cloudServices: number, other: number, staff: number) {
|
||||
public updateScore(score: Score, total: number, activity: number, roles: number, moderation: number, cloudServices: number, other: number, staff: number) {
|
||||
return this.queues.score.add('score::update', { score, total, activity, roles, moderation, cloudServices, other, staff });
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { v4 as uuid } from 'uuid';
|
||||
import { InqType } from 'cr-db/mongodb';
|
||||
import { Client } from '.';
|
||||
import { InqType } from '../models';
|
||||
|
||||
export default class Report {
|
||||
public client: Client;
|
||||
|
@ -10,11 +10,11 @@ export default class Report {
|
|||
}
|
||||
|
||||
public async createInquiry(userID: string, name: string, type: InqType, reason?: string) {
|
||||
const report = await this.client.db.Score.findOne({ userID }).lean().exec();
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID }).lean().exec();
|
||||
const member = this.client.util.resolveMember(userID, this.client.guilds.get(this.client.config.guildID));
|
||||
if (!report || !member) return null;
|
||||
if (type === InqType.HARD && report.locked) return null;
|
||||
const mod = await (new this.client.db.Inquiry({
|
||||
if (type === InqType.Hard && report.locked) return null;
|
||||
const mod = await (new this.client.db.mongo.Inquiry({
|
||||
iid: uuid(),
|
||||
userID,
|
||||
name,
|
||||
|
@ -30,7 +30,7 @@ export default class Report {
|
|||
}
|
||||
|
||||
/* public async soft(userID: string) {
|
||||
const report = await this.client.db.Score.findOne({ userID });
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID });
|
||||
if (!report) return null;
|
||||
let totalScore: number;
|
||||
let activityScore: number;
|
||||
|
@ -59,7 +59,7 @@ export default class Report {
|
|||
else if (report.cloudServices > 10) cloudServicesScore = 10;
|
||||
else cloudServicesScore = Math.round(report.cloudServices);
|
||||
|
||||
const historicalData = await this.client.db.ScoreHistorical.find({ userID: member.userID }).lean().exec();
|
||||
const historicalData = await this.client.db.mongo.ScoreHistorical.find({ userID: member.userID }).lean().exec();
|
||||
const array: ScoreHistoricalRaw[] = [];
|
||||
for (const data of historicalData) {
|
||||
let total: number;
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class Route {
|
|||
public init() {
|
||||
this.router.all('*', (req, res, next) => {
|
||||
this.server.client.util.signale.log(`'${req.method}' request from '${req.ip}' to '${req.hostname}${req.path}'.`);
|
||||
this.server.client.db.Stat.updateOne({ name: 'requests' }, { $inc: { value: 1 } }).exec();
|
||||
this.server.client.db.mongo.Stat.updateOne({ name: 'requests' }, { $inc: { value: 1 } }).exec();
|
||||
if (this.conf.maintenance === true) res.status(503).json({ code: this.constants.codes.MAINTENANCE_OR_UNAVAILABLE, message: this.constants.messages.MAINTENANCE_OR_UNAVAILABLE });
|
||||
else if (this.conf.deprecated === true) res.status(501).json({ code: this.constants.codes.DEPRECATED, message: this.constants.messages.DEPRECATED });
|
||||
else next();
|
||||
|
|
|
@ -23,9 +23,9 @@ export default class AddItem extends Command {
|
|||
return message.channel.createMessage({ embed });
|
||||
}
|
||||
if (args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(args[0].split('-')[1])) {
|
||||
const account = await this.client.db.Member.findOne({ userID: message.member.id });
|
||||
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
|
||||
if (!account) {
|
||||
const newAccount = new this.client.db.Member({
|
||||
const newAccount = new this.client.db.mongo.Member({
|
||||
userID: message.member.id,
|
||||
additional: {
|
||||
operatingSystems: [args[0].split('-')[1]],
|
||||
|
@ -38,9 +38,9 @@ export default class AddItem extends Command {
|
|||
return message.channel.createMessage(`***${this.client.util.emojis.SUCCESS} Added OS code ${args[0]} to profile.***`);
|
||||
}
|
||||
if (args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(args[0].split('-')[1])) {
|
||||
const account = await this.client.db.Member.findOne({ userID: message.member.id });
|
||||
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
|
||||
if (!account) {
|
||||
const newAccount = new this.client.db.Member({
|
||||
const newAccount = new this.client.db.mongo.Member({
|
||||
userID: message.member.id,
|
||||
additional: {
|
||||
langs: [args[0].split('-')[1]],
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class AddMerchant extends Command {
|
|||
if ((Number(args[0]) !== 0) && (Number(args[0]) !== 1)) return this.error(message.channel, 'Invalid permissions.');
|
||||
if ((Number(args[1]) !== 0) && (Number(args[1]) !== 1)) return this.error(message.channel, 'Invalid permissions.');
|
||||
const key = randomBytes(20).toString('hex');
|
||||
const merchant = await (new this.client.db.Merchant({
|
||||
const merchant = await (new this.client.db.mongo.Merchant({
|
||||
name: args.slice(2).join(' '),
|
||||
privileged: Number(args[0]),
|
||||
type: Number(args[1]),
|
||||
|
|
|
@ -31,7 +31,7 @@ export default class AddNote extends Command {
|
|||
note.category = args[args.length - 1];
|
||||
note.text = args.slice(0, args.length - 1).join(' ');
|
||||
}
|
||||
const saved = await (new this.client.db.Note(note).save());
|
||||
const saved = await (new this.client.db.mongo.Note(note).save());
|
||||
return this.success(message.channel, `Successfully created Note # \`${saved._id}\`.`);
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class AddPromoCode extends Command {
|
|||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
try {
|
||||
const pcd = await this.client.stripe.promotionCodes.retrieve(args[0]);
|
||||
const promo = new this.client.db.Promo({
|
||||
const promo = new this.client.db.mongo.Promo({
|
||||
code: pcd.code,
|
||||
pID: args[0],
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class AddRank extends Command {
|
|||
const role = this.client.util.resolveRole(args[0], this.mainGuild);
|
||||
if (!role) return this.error(message.channel, 'The role you specified doesn\'t appear to exist.');
|
||||
|
||||
const check = await this.client.db.Rank.findOne({ roleID: role.id });
|
||||
const check = await this.client.db.mongo.Rank.findOne({ roleID: role.id });
|
||||
if (check) return this.error(message.channel, 'This role is already self-assignable.');
|
||||
|
||||
let permissions: string[];
|
||||
|
@ -30,7 +30,7 @@ export default class AddRank extends Command {
|
|||
permissions = args[1].split(':');
|
||||
}
|
||||
|
||||
const entry = new this.client.db.Rank({
|
||||
const entry = new this.client.db.mongo.Rank({
|
||||
name: role.name,
|
||||
roleID: role.id,
|
||||
permissions,
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class AddRedirect extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const check = await this.client.db.Redirect.findOne({ key: args[1].toLowerCase() });
|
||||
const check = await this.client.db.mongo.Redirect.findOne({ key: args[1].toLowerCase() });
|
||||
if (check) return this.error(message.channel, `Redirect key ${args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
|
||||
try {
|
||||
const test = new URL(args[0]);
|
||||
|
@ -24,7 +24,7 @@ export default class AddRedirect extends Command {
|
|||
return this.error(message.channel, 'This doesn\'t appear to be a valid URL.');
|
||||
}
|
||||
if ((/^[a-zA-Z0-9]+$/gi.test(args[1].toLowerCase().replace('-', '').trim()) === false) || args[1].toLowerCase().length > 15) return this.error(message.channel, 'Invalid key. The key must be alphanumeric and less than 16 characters.');
|
||||
const redirect = new this.client.db.Redirect({
|
||||
const redirect = new this.client.db.mongo.Redirect({
|
||||
key: args[1].toLowerCase(),
|
||||
to: args[0],
|
||||
visitedCount: 0,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import type { AxiosError, AxiosStatic } from 'axios';
|
||||
import axios from 'axios';
|
||||
import { Member, Message } from 'eris';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
import { CloudServicesUtil } from '../util';
|
||||
|
||||
|
@ -74,29 +75,46 @@ export default class Apply extends Command {
|
|||
},
|
||||
});
|
||||
|
||||
this.services.set('cs::cwgss', {
|
||||
description: 'Authentication token to use for creating a subdomain on your own. See `=cwg selvserv` for more information.',
|
||||
type: 'SOFT',
|
||||
url: 'https://eds.libraryofcode.org/cs/cwgss',
|
||||
validation: async (member: Member) => {
|
||||
if (!member.roles.includes('546457886440685578')) return false;
|
||||
},
|
||||
func: async (client: Client, ...data: any[]) => {
|
||||
const token = nanoid();
|
||||
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||
|
||||
const dmChannel = await this.client.getDMChannel(member.id);
|
||||
await dmChannel.createMessage(`__**CWG Self-Serv Authentication Token**__ \`${token}\`\n\n*This token expires in 30 minutes.*`);
|
||||
client.db.redis.set(token, data[0], 'ex', '1800');
|
||||
},
|
||||
});
|
||||
|
||||
this.services.set('cs::temp-upgrade', {
|
||||
description: 'Temporary Tier 3 upgrade for your Cloud Services account to install dependencies or RAM-dependent operations.',
|
||||
type: 'SOFT',
|
||||
url: 'https://eds.libraryofcode.org/cs/t3-temp',
|
||||
validation: async (member: Member) => {
|
||||
const csAccount = await CloudServicesUtil.fetchAccountStatus(member.id, this.client.config.internalKey);
|
||||
const memberCheck = await this.client.db.Member.findOne({ userID: member.id }).lean().exec();
|
||||
const memberCheck = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec();
|
||||
if (new Date() > memberCheck?.misc?.t3TemporaryExpiration?.date) return false;
|
||||
if (csAccount.tier === 3) return false;
|
||||
return true;
|
||||
},
|
||||
func: async (client: Client, ...data: any[]) => {
|
||||
const dmember = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||
const member = await this.client.db.Member.findOne({ userID: dmember.id }).lean().exec();
|
||||
const member = await this.client.db.mongo.Member.findOne({ userID: dmember.id }).lean().exec();
|
||||
const CloudServicesUtilP = <typeof CloudServicesUtil>require('../util/CloudServices').default;
|
||||
const csAccount = await CloudServicesUtilP.fetchAccountStatus(dmember.id, this.client.config.internalKey);
|
||||
if (!member) {
|
||||
const addMember = new this.client.db.Member({
|
||||
const addMember = new this.client.db.mongo.Member({
|
||||
userID: dmember.id,
|
||||
});
|
||||
await addMember.save();
|
||||
}
|
||||
this.client.db.Member.updateOne({ userID: dmember.id }, { $set: { misc: { t3TemporaryExpiration: { processed: false, date: new Date(Date.now() + 1800000), previousTier: csAccount.tier } } } }).exec();
|
||||
this.client.db.mongo.Member.updateOne({ userID: dmember.id }, { $set: { misc: { t3TemporaryExpiration: { processed: false, date: new Date(Date.now() + 1800000), previousTier: csAccount.tier } } } }).exec();
|
||||
|
||||
await CloudServicesUtilP.setTier(dmember.id, 3, this.client.config.internalKey);
|
||||
},
|
||||
|
@ -108,13 +126,13 @@ export default class Apply extends Command {
|
|||
url: 'https://eds.libraryofcode.org/cs/t3-promo',
|
||||
validation: async (member: Member) => {
|
||||
if (!member.roles.includes('546457886440685578')) return false;
|
||||
const customer = await this.client.db.Customer.findOne({ userID: member.user.id }).lean().exec();
|
||||
const customer = await this.client.db.mongo.Customer.findOne({ userID: member.user.id }).lean().exec();
|
||||
if (!customer) return false;
|
||||
return true;
|
||||
},
|
||||
func: async (client: Client, ...data: any[]) => {
|
||||
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||
const customer = await client.db.Customer.findOne({ userID: member.user.id }).lean().exec();
|
||||
const customer = await client.db.mongo.Customer.findOne({ userID: member.user.id }).lean().exec();
|
||||
const coupon = await client.stripe.coupons.create({
|
||||
percent_off: 25,
|
||||
duration: 'once',
|
||||
|
@ -132,7 +150,7 @@ export default class Apply extends Command {
|
|||
first_time_transaction: true,
|
||||
},
|
||||
});
|
||||
const doc = new client.db.Promo({
|
||||
const doc = new client.db.mongo.Promo({
|
||||
code: promo.code,
|
||||
pID: promo.id,
|
||||
});
|
||||
|
|
|
@ -30,11 +30,11 @@ export default class Billing extends Command {
|
|||
|
||||
const portalKey = randomBytes(50).toString('hex');
|
||||
const uid = uuid();
|
||||
const redirect = new this.client.db.Redirect({
|
||||
const redirect = new this.client.db.mongo.Redirect({
|
||||
key: uid,
|
||||
to: `https://loc.sh/dash?q=${portalKey}`,
|
||||
});
|
||||
const portal = new this.client.db.CustomerPortal({
|
||||
const portal = new this.client.db.mongo.CustomerPortal({
|
||||
key: portalKey,
|
||||
username: message.author.username,
|
||||
userID: message.author.id,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import axios from 'axios';
|
||||
import Database from 'cr-db';
|
||||
import { Message } from 'eris';
|
||||
import type { Stripe } from 'stripe';
|
||||
import { Client, Command } from '../class';
|
||||
import type { PromoInterface } from '../models';
|
||||
|
||||
export default class Billing_T3 extends Command {
|
||||
constructor(client: Client) {
|
||||
|
@ -26,12 +26,12 @@ export default class Billing_T3 extends Command {
|
|||
}>(await axios.get(`https://api.cloud.libraryofcode.org/wh/info?id=${message.author.id}&authorization=${this.client.config.internalKey}`)).data;
|
||||
if (!response.found) return this.error(message.channel, 'CS Account not found.');
|
||||
|
||||
const customer = await this.client.db.Customer.findOne({ userID: message.author.id });
|
||||
const customer = await this.client.db.mongo.Customer.findOne({ userID: message.author.id });
|
||||
if (!customer) return this.error(message.channel, `You do not have a Customer Account. Please run \`${this.client.config.prefix}billing\`, once you visit the Billing Portal via the URL given to you, please try again.`);
|
||||
|
||||
let promoCode: PromoInterface;
|
||||
let promoCode;
|
||||
if (args[0]) {
|
||||
promoCode = await this.client.db.Promo.findOne({ code: args[0].toUpperCase() });
|
||||
promoCode = await this.client.db.mongo.Promo.findOne({ code: args[0].toUpperCase() });
|
||||
}
|
||||
|
||||
let subscription: Stripe.Response<Stripe.Subscription>;
|
||||
|
|
|
@ -29,7 +29,7 @@ export default class Callback extends Command {
|
|||
embed.addField('Member', `${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`, true);
|
||||
embed.addField('Phone Number', phone.getNumber('national'), true);
|
||||
embed.addField('Phone Number Type', phone.getType(), true);
|
||||
const communityReport = await this.client.db.Score.findOne({ userID: message.author.id }).lean().exec();
|
||||
const communityReport = await this.client.db.mongo.Score.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (communityReport) {
|
||||
await this.client.report.createInquiry(member.user.id, 'Library of Code sp-us | VOIP/PBX Member Support SVCS', 1);
|
||||
embed.addField('PIN', `${communityReport.pin[0]}-${communityReport.pin[1]}-${communityReport.pin[2]}`, true);
|
||||
|
|
|
@ -23,7 +23,7 @@ export default class DelItem extends Command {
|
|||
return message.channel.createMessage({ embed });
|
||||
}
|
||||
if (args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(args[0].split('-')[1])) {
|
||||
const account = await this.client.db.Member.findOne({ userID: message.member.id });
|
||||
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
|
||||
if (account?.additional.operatingSystems.length < 1) {
|
||||
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any operating systems to remove.***`);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export default class DelItem extends Command {
|
|||
return message.channel.createMessage(`***${this.client.util.emojis.SUCCESS} Removed OS code ${args[0]} from profile.***`);
|
||||
}
|
||||
if (args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(args[0].split('-')[1])) {
|
||||
const account = await this.client.db.Member.findOne({ userID: message.member.id });
|
||||
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
|
||||
if (account?.additional.langs.length < 1) {
|
||||
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any languages to remove.***`);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class DelMerchant extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const merchant = await this.client.db.Merchant.findOne({ key: args[0] });
|
||||
const merchant = await this.client.db.mongo.Merchant.findOne({ key: args[0] });
|
||||
if (!merchant) return this.error(message.channel, 'Merchant specified does not exist.');
|
||||
return this.success(message.channel, `Deleted merchant \`${merchant._id}\`.`);
|
||||
} catch (err) {
|
||||
|
|
|
@ -15,9 +15,9 @@ export default class DelNote extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const note = await this.client.db.Note.findOne({ _id: args[0] }).lean().exec().catch(() => {});
|
||||
const note = await this.client.db.mongo.Note.findOne({ _id: args[0] }).lean().exec().catch(() => {});
|
||||
if (!note) return this.error(message.channel, 'Could not locate that note.');
|
||||
await this.client.db.Note.deleteOne({ _id: note._id });
|
||||
await this.client.db.mongo.Note.deleteOne({ _id: note._id });
|
||||
return this.success(message.channel, `Note # \`${note._id}\` has been deleted.`);
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class DeletePromoCode extends Command {
|
|||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
try {
|
||||
await this.client.stripe.promotionCodes.retrieve(args[0]);
|
||||
await this.client.db.Promo.deleteOne({ pID: args[0] }).lean().exec();
|
||||
await this.client.db.mongo.Promo.deleteOne({ pID: args[0] }).lean().exec();
|
||||
} catch (err) {
|
||||
return this.error(message.channel, 'Promotional API ID doesn\'t exist.');
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ export default class DelRank extends Command {
|
|||
const role = this.client.util.resolveRole(args[0], this.mainGuild);
|
||||
if (!role) return this.error(message.channel, 'The role you specified doesn\'t appear to exist.');
|
||||
|
||||
const check = await this.client.db.Rank.findOne({ roleID: role.id });
|
||||
const check = await this.client.db.mongo.Rank.findOne({ roleID: role.id });
|
||||
if (!check) return this.error(message.channel, 'The entry doesn\'t appear to exist.');
|
||||
|
||||
await this.client.db.Rank.deleteOne({ roleID: role.id });
|
||||
await this.client.db.mongo.Rank.deleteOne({ roleID: role.id });
|
||||
return this.success(message.channel, `Role ${role.name} is no longer self-assignable.`);
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
|
|
|
@ -15,9 +15,9 @@ export default class DelRedirect extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const check = await this.client.db.Redirect.findOne({ key: args[0].toLowerCase() });
|
||||
const check = await this.client.db.mongo.Redirect.findOne({ key: args[0].toLowerCase() });
|
||||
if (!check) return this.error(message.channel, `Redirect key ${args[0].toLowerCase()} doesn't exist.`);
|
||||
await this.client.db.Redirect.deleteOne({ key: args[0].toLowerCase() });
|
||||
await this.client.db.mongo.Redirect.deleteOne({ key: args[0].toLowerCase() });
|
||||
return this.success(message.channel, `Deleted redirect https://loc.sh/${args[0].toLowerCase()}.`);
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
|
|
|
@ -23,9 +23,9 @@ export default class Inquiry extends Command {
|
|||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
|
||||
const inquiry = await this.client.db.Inquiry.findOne({ iid: args[0] });
|
||||
const inquiry = await this.client.db.mongo.Inquiry.findOne({ iid: args[0] });
|
||||
if (!inquiry) return this.error(message.channel, 'Could not locate Inquiry information.');
|
||||
const currentReport = await this.client.db.Score.findOne({ userID: inquiry.userID });
|
||||
const currentReport = await this.client.db.mongo.Score.findOne({ userID: inquiry.userID });
|
||||
if (!currentReport) return this.error(message.channel, 'Could not find Community Report for this user.');
|
||||
const member = this.client.util.resolveMember(inquiry.userID, this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Could not locate member.');
|
||||
|
|
|
@ -20,16 +20,16 @@ export default class Inquiry_Remove extends Command {
|
|||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
|
||||
const inquiry = await this.client.db.Inquiry.findOne({ iid: args[0] });
|
||||
const inquiry = await this.client.db.mongo.Inquiry.findOne({ iid: args[0] });
|
||||
if (!inquiry) return this.error(message.channel, 'Unable to find Inquiry.');
|
||||
const member = await this.client.util.resolveMember(inquiry.userID, this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Unable to locate member.');
|
||||
const report = await this.client.db.Score.findOne({ userID: member.id });
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID: member.id });
|
||||
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
|
||||
|
||||
if (inquiry.type !== 0) return this.error(message.channel, 'You can only remove Hard Inquiries.');
|
||||
|
||||
await this.client.db.Inquiry.deleteOne({ iid: args[0] });
|
||||
await this.client.db.mongo.Inquiry.deleteOne({ iid: args[0] });
|
||||
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Inquiry - Removed');
|
||||
|
|
|
@ -21,7 +21,7 @@ export default class Judgement_Add extends Command {
|
|||
|
||||
const member = this.client.util.resolveMember(args[0], this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Unable to locate member.');
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
|
||||
|
||||
if (Number.isNaN(Number(args[1]))) return this.error(message.channel, 'Severity must be a number.');
|
||||
|
@ -41,7 +41,7 @@ export default class Judgement_Add extends Command {
|
|||
|
||||
const jid = nanoid(11);
|
||||
|
||||
const entry = new this.client.db.Judgement({
|
||||
const entry = new this.client.db.mongo.Judgement({
|
||||
jid,
|
||||
userID: member.user.id,
|
||||
enteredBy: message.author.id,
|
||||
|
|
|
@ -19,9 +19,9 @@ export default class Judgement_Delete extends Command {
|
|||
|
||||
const member = this.client.util.resolveMember(args[0], this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Unable to locate member.');
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
|
||||
const judgement = await this.client.db.Judgement.findOne({ jid: args[0] });
|
||||
const judgement = await this.client.db.mongo.Judgement.findOne({ jid: args[0] });
|
||||
if (!judgement) return this.error(message.channel, 'Unable to locate judgement.');
|
||||
|
||||
await judgement.delete();
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class DelRedirect extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (args[0]) {
|
||||
const redirects = await this.client.db.Redirect.find({ $or: [{ key: args[0].toLowerCase() }, { to: args[0].toLowerCase() }] });
|
||||
const redirects = await this.client.db.mongo.Redirect.find({ $or: [{ key: args[0].toLowerCase() }, { to: args[0].toLowerCase() }] });
|
||||
if (redirects.length <= 0) return this.error(message.channel, 'Could not find an entry matching that query.');
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Redirect Information');
|
||||
|
@ -27,7 +27,7 @@ export default class DelRedirect extends Command {
|
|||
embed.setTimestamp();
|
||||
return message.channel.createMessage({ embed });
|
||||
}
|
||||
const redirects = await this.client.db.Redirect.find();
|
||||
const redirects = await this.client.db.mongo.Redirect.find();
|
||||
if (!redirects) return this.error(message.channel, 'No redirect links found.');
|
||||
const redirectArray: [{ name: string, value: string }?] = [];
|
||||
for (const redirect of redirects) {
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class Mute extends Command {
|
|||
if (!member) return this.error(message.channel, 'Cannot find user.');
|
||||
|
||||
try {
|
||||
const res1 = await this.client.db.local.muted.get<boolean>(`muted-${member.id}`);
|
||||
const res1 = await this.client.db.mongo.local.muted.get<boolean>(`muted-${member.id}`);
|
||||
if (res1 || this.mainGuild.members.get(member.id).roles.includes('478373942638149643')) return this.error(message.channel, 'This user is already muted.');
|
||||
} catch {} // eslint-disable-line no-empty
|
||||
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class Notes extends Command {
|
|||
}
|
||||
if (!member) return this.error(message.channel, 'User specified could not be found.');
|
||||
|
||||
const notes = await this.client.db.Note.find({ userID: member.id });
|
||||
const notes = await this.client.db.mongo.Note.find({ userID: member.id });
|
||||
if (!notes || notes?.length < 1) return this.error(message.channel, 'No notes exist for this user.');
|
||||
|
||||
const noteArray: [{ name: string, value: string, inline: boolean }?] = [];
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class Offer extends Command {
|
|||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const member = this.client.util.resolveMember(args[0], this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Could not find member.');
|
||||
const score = await this.client.db.Score.findOne({ userID: member.user.id }).lean().exec();
|
||||
const score = await this.client.db.mongo.Score.findOne({ userID: member.user.id }).lean().exec();
|
||||
if (!score) return this.error(message.channel, 'Could not find score report for this user.');
|
||||
|
||||
if (score.locked) return this.error(message.channel, 'This user\'s score report is locked.');
|
||||
|
|
|
@ -54,7 +54,7 @@ export default class Page extends Command {
|
|||
return message.channel.createMessage({ embed });
|
||||
}
|
||||
if (args[0] === 'settings') {
|
||||
const pager = await this.client.db.PagerNumber.findOne({ individualAssignID: message.author.id });
|
||||
const pager = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: message.author.id });
|
||||
if (!pager) return this.error(message.channel, 'You do not have a Pager Number.');
|
||||
switch (args[1]) {
|
||||
case 'email':
|
||||
|
@ -88,7 +88,7 @@ export default class Page extends Command {
|
|||
}
|
||||
message.delete();
|
||||
const loading = await this.loading(message.channel, 'Paging...');
|
||||
const sender = await this.client.db.PagerNumber.findOne({ individualAssignID: message.author.id });
|
||||
const sender = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: message.author.id });
|
||||
if (!sender) return this.error(message.channel, 'You do not have a Pager Number.');
|
||||
const page = await this.page(args[0], sender.num, args[1], message, args[2] ? args.slice(2).join(' ') : undefined);
|
||||
if (page.status === true) {
|
||||
|
@ -111,7 +111,7 @@ export default class Page extends Command {
|
|||
public async page(recipientNumber: string, senderNumber: string, code: string, message: Message, txt?: string, options?: { emergencyNumber: string }): Promise<{status: boolean, message: string}> {
|
||||
try {
|
||||
if (txt?.length >= 140) return { status: false, message: 'Your message must be less than 141 characters.' };
|
||||
const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber });
|
||||
const senderEntry = await this.client.db.mongo.PagerNumber.findOne({ num: senderNumber });
|
||||
if (!senderEntry) {
|
||||
return { status: false, message: 'You do not have a Pager Number.' };
|
||||
}
|
||||
|
@ -129,9 +129,9 @@ export default class Page extends Command {
|
|||
await this.page('20', senderNumber, code, message, txt, { emergencyNumber: '1' });
|
||||
break;
|
||||
case '#2':
|
||||
const matthew = await this.client.db.PagerNumber.findOne({ individualAssignID: '278620217221971968' });
|
||||
const bsian = await this.client.db.PagerNumber.findOne({ individualAssignID: '253600545972027394' });
|
||||
const nightraven = await this.client.db.PagerNumber.findOne({ individualAssignID: '239261547959025665' });
|
||||
const matthew = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: '278620217221971968' });
|
||||
const bsian = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: '253600545972027394' });
|
||||
const nightraven = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: '239261547959025665' });
|
||||
await this.page(matthew?.num, senderNumber, code, message, txt, { emergencyNumber: '2' });
|
||||
await this.page(bsian?.num, senderNumber, code, message, txt, { emergencyNumber: '2' });
|
||||
await this.page(nightraven?.num, senderNumber, code, message, txt, { emergencyNumber: '2' });
|
||||
|
@ -148,7 +148,7 @@ export default class Page extends Command {
|
|||
}
|
||||
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
|
||||
}
|
||||
const recipientEntry = await this.client.db.PagerNumber.findOne({ num: recipientNumber });
|
||||
const recipientEntry = await this.client.db.mongo.PagerNumber.findOne({ num: recipientNumber });
|
||||
if (!recipientEntry) {
|
||||
return { status: false, message: `Pager Number \`${recipientNumber}\` does not exist.` };
|
||||
}
|
||||
|
@ -186,9 +186,9 @@ export default class Page extends Command {
|
|||
}
|
||||
|
||||
/* for (const id of recipientEntry.discordIDs) {
|
||||
const pager = await this.client.db.PagerNumber.findOne({ individualAssignID: id });
|
||||
const pager = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: id });
|
||||
if (!pager || !pager.receivePhone) continue;
|
||||
const member = await this.client.db.Staff.findOne({ userID: pager.individualAssignID });
|
||||
const member = await this.client.db.mongo.Staff.findOne({ userID: pager.individualAssignID });
|
||||
if (!member || !member.extension) continue;
|
||||
|
||||
const fileExtension = `${randomBytes(10).toString('hex')}`;
|
||||
|
@ -230,7 +230,7 @@ export default class Page extends Command {
|
|||
this.client.util.signale.log(`Unable to Dial ${member.extension} | ${err}`);
|
||||
}
|
||||
} */
|
||||
this.client.db.Stat.updateOne({ name: 'pages' }, { $inc: { value: 1 } }).exec();
|
||||
this.client.db.mongo.Stat.updateOne({ name: 'pages' }, { $inc: { value: 1 } }).exec();
|
||||
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
|
||||
} catch (err) {
|
||||
this.client.util.signale.error(err);
|
||||
|
|
|
@ -39,7 +39,7 @@ export default class PGP extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
const profile = await this.client.db.Member.findOne({ userID: args[0] || message.author.id });
|
||||
const profile = await this.client.db.mongo.Member.findOne({ userID: args[0] || message.author.id });
|
||||
if (!profile) return this.error(message.channel, 'Unable to find specified member\'s account.');
|
||||
const embed = new RichEmbed()
|
||||
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL())
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class PGP_Remove extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message) {
|
||||
const profile = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
const profile = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
|
||||
if (!profile?.pgp) return this.error(message.channel, 'There are no PGP public keys connected to your account.');
|
||||
await profile.updateOne({ $unset: { pgp: '' } });
|
||||
this.success(message.channel, 'Unlinked PGP public key from your account.');
|
||||
|
|
|
@ -16,8 +16,8 @@ export default class PGP_Upload extends Command {
|
|||
|
||||
public async run(message: Message) {
|
||||
if (!message.attachments.length) return this.error(message.channel, 'Please upload your PGP public key as an attachment.');
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.mongo.Member.create({ userID: message.author.id });
|
||||
}
|
||||
const [pgpAttachment] = message.attachments;
|
||||
const pgpReq: AxiosResponse<string> = await axios(pgpAttachment.url);
|
||||
|
@ -27,7 +27,7 @@ export default class PGP_Upload extends Command {
|
|||
} catch {
|
||||
return this.error(message.channel, 'Unable to parse your PGP public key.');
|
||||
}
|
||||
await this.client.db.Member.updateOne({ userID: message.author.id }, { pgp });
|
||||
await this.client.db.mongo.Member.updateOne({ userID: message.author.id }, { pgp });
|
||||
this.success(message.channel, 'PGP public key successfully uploaded to your account.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ export default class Profile extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message) {
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.mongo.Member.create({ userID: message.author.id });
|
||||
}
|
||||
|
||||
this.error(message.channel, `Please specify a valid option to change. Choose from \`github\`, \`bio\` and \`gitlab\`. You can view your profile with \`${this.client.config.prefix}whois\`.`);
|
||||
|
|
|
@ -12,10 +12,10 @@ export default class Profile_Bio extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.mongo.Member.create({ userID: message.author.id });
|
||||
}
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
const member = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
|
||||
|
||||
if (!args[0]) {
|
||||
await member.updateOne({
|
||||
|
|
|
@ -12,10 +12,10 @@ export default class Profile_GitHub extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.mongo.Member.create({ userID: message.author.id });
|
||||
}
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
const member = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
|
||||
if (!args[0]) {
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
|
|
|
@ -12,11 +12,11 @@ export default class Profile_GitLab extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.mongo.Member.create({ userID: message.author.id });
|
||||
}
|
||||
if (!args[0]) return this.error(message.channel, 'No GitLab profile URL was provided.');
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
const member = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
|
||||
if (!args[0]) {
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class Rank extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) {
|
||||
const roles = await this.client.db.Rank.find();
|
||||
const roles = await this.client.db.mongo.Rank.find();
|
||||
const rankArray: [{ name: string, value: string }?] = [];
|
||||
for (const rank of roles.sort((a, b) => a.name.localeCompare(b.name))) {
|
||||
let perms: string;
|
||||
|
@ -49,7 +49,7 @@ export default class Rank extends Command {
|
|||
}
|
||||
const role = this.client.util.resolveRole(args.join(' '), this.client.guilds.get(this.client.config.guildID));
|
||||
if (!role) return this.error(message.channel, 'The role you specified doesn\'t exist.');
|
||||
const entry = await this.client.db.Rank.findOne({ roleID: role.id }).lean().exec();
|
||||
const entry = await this.client.db.mongo.Rank.findOne({ roleID: role.id }).lean().exec();
|
||||
if (!entry) return this.error(message.channel, 'The rank you specified doesn\'t exist.');
|
||||
if (!message.member.roles.includes(entry.roleID)) {
|
||||
let permCheck: boolean;
|
||||
|
|
|
@ -27,9 +27,9 @@ export default class StaffAssistedApplication extends Command {
|
|||
|
||||
const member = this.client.util.resolveMember(args[0], this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Unable to locate member.');
|
||||
const report = await this.client.db.Score.findOne({ userID: member.id }).lean().exec();
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID: member.id }).lean().exec();
|
||||
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
|
||||
|
||||
const service = this.applyCommand.services.get(args[1]);
|
||||
|
@ -42,7 +42,7 @@ export default class StaffAssistedApplication extends Command {
|
|||
|
||||
const application = await Apply.apply(this.client, service.url, member.id);
|
||||
|
||||
await (new this.client.db.SAA({
|
||||
await (new this.client.db.mongo.SAA({
|
||||
userID: member.id,
|
||||
applicationID: application.id,
|
||||
serviceCode: args[1],
|
||||
|
|
|
@ -22,13 +22,13 @@ export default class SAA_Approve extends Command {
|
|||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
|
||||
const saa = await this.client.db.SAA.findOne({ applicationID: args[0] }).lean().exec();
|
||||
const saa = await this.client.db.mongo.SAA.findOne({ applicationID: args[0] }).lean().exec();
|
||||
if (!saa) return this.error(message.channel, 'Unable to locate SAA.');
|
||||
const member = this.client.util.resolveMember(saa.userID, this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Unable to locate member.');
|
||||
const report = await this.client.db.Score.findOne({ userID: saa.userID }).lean().exec();
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID: saa.userID }).lean().exec();
|
||||
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
|
||||
|
||||
await this.applyCommand.services.get(saa.serviceCode).func(this.client, member.id);
|
||||
|
@ -52,13 +52,17 @@ export default class SAA_Approve extends Command {
|
|||
const chan = await this.client.getDMChannel(saa.userID);
|
||||
chan.createMessage({ embed }).then(() => this.success(message.channel, 'SAA successfully processed.')).catch(() => this.error(message.channel, 'Unable to deliver decision to user.'));
|
||||
|
||||
try {
|
||||
await axios({
|
||||
method: 'PATCH',
|
||||
url: `https://eds.libraryofcode.org/dec/${saa.applicationID}?auth=${this.client.config.internalKey}`,
|
||||
data: { status: true },
|
||||
});
|
||||
} catch (e) {
|
||||
this.error(message.channel, `An error occurred while changing EDS data: ${e}`);
|
||||
}
|
||||
|
||||
await this.client.db.SAA.deleteOne({ _id: saa._id }).lean().exec();
|
||||
await this.client.db.mongo.SAA.deleteOne({ _id: saa._id }).lean().exec();
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ export default class SAA_Decline extends Command {
|
|||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
|
||||
const saa = await this.client.db.SAA.findOne({ applicationID: args[0] }).lean().exec();
|
||||
const saa = await this.client.db.mongo.SAA.findOne({ applicationID: args[0] }).lean().exec();
|
||||
if (!saa) return this.error(message.channel, 'Unable to locate SAA.');
|
||||
const member = this.client.util.resolveMember(saa.userID, this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Unable to locate member.');
|
||||
const report = await this.client.db.Score.findOne({ userID: saa.userID }).lean().exec();
|
||||
const report = await this.client.db.mongo.Score.findOne({ userID: saa.userID }).lean().exec();
|
||||
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
|
||||
|
||||
const embed = new RichEmbed();
|
||||
|
@ -49,7 +49,7 @@ export default class SAA_Decline extends Command {
|
|||
const chan = await this.client.getDMChannel(saa.userID);
|
||||
chan.createMessage({ embed }).then(() => this.success(message.channel, 'SAA successfully processed.')).catch(() => this.error(message.channel, 'Unable to deliver decision to user.'));
|
||||
|
||||
await this.client.db.SAA.deleteOne({ _id: saa._id }).lean().exec();
|
||||
await this.client.db.mongo.SAA.deleteOne({ _id: saa._id }).lean().exec();
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ export default class Score extends Command {
|
|||
} else {
|
||||
user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
|
||||
if (!user) {
|
||||
const sc = await this.client.db.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
|
||||
const sc = await this.client.db.mongo.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
|
||||
if (!sc) return this.error(message.channel, 'Member not found.');
|
||||
user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user;
|
||||
}
|
||||
|
@ -45,15 +45,15 @@ export default class Score extends Command {
|
|||
if (args.length < 3) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const name = args.slice(2).join(' ').split(':')[0];
|
||||
const reason = args.slice(2).join(' ').split(':')[1];
|
||||
const score = await this.client.db.Score.findOne({ userID: user.id });
|
||||
const score = await this.client.db.mongo.Score.findOne({ userID: user.id });
|
||||
if (!score) return this.error(message.channel, 'Score not calculated yet.');
|
||||
if (score.locked) return this.error(message.channel, 'The score report you have requested has been locked.');
|
||||
await this.client.report.createInquiry(score.userID, name, 0, reason);
|
||||
}
|
||||
}
|
||||
if (!user) return this.error(message.channel, 'Member not found.');
|
||||
const score = await this.client.db.Score.findOne({ userID: user.id });
|
||||
const inqs = await this.client.db.Inquiry.find({ userID: user.id, type: 0 });
|
||||
const score = await this.client.db.mongo.Score.findOne({ userID: user.id });
|
||||
const inqs = await this.client.db.mongo.Inquiry.find({ userID: user.id, type: 0 });
|
||||
if (!score) return this.error(message.channel, 'Community Report has not been generated yet.');
|
||||
let totalScore = '0';
|
||||
let activityScore = '0';
|
||||
|
@ -90,7 +90,7 @@ export default class Score extends Command {
|
|||
} // else return this.error(message.channel, 'Community Score has not been calculated yet.');
|
||||
|
||||
const set = [];
|
||||
const accounts = await this.client.db.Score.find().lean().exec();
|
||||
const accounts = await this.client.db.mongo.Score.find().lean().exec();
|
||||
for (const sc of accounts) {
|
||||
if (sc.total < 200) { continue; }
|
||||
if (sc.total > 800) { set.push(800); continue; }
|
||||
|
@ -140,7 +140,7 @@ export default class Score extends Command {
|
|||
embed.addField('Other', otherScore || 'N/C', true);
|
||||
embed.addField('Misc', miscScore || 'N/C', true);
|
||||
let judgementsStr: string = '';
|
||||
const judgements = await this.client.db.Judgement.find({ userID: user.id }).lean().exec();
|
||||
const judgements = await this.client.db.mongo.Judgement.find({ userID: user.id }).lean().exec();
|
||||
if (judgements?.length > 0) {
|
||||
for (const judgement of judgements) {
|
||||
let severity: string;
|
||||
|
|
|
@ -29,7 +29,7 @@ export default class Score_Hist extends Command {
|
|||
} else {
|
||||
user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
|
||||
if (!user) {
|
||||
const sc = await this.client.db.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
|
||||
const sc = await this.client.db.mongo.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
|
||||
user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user;
|
||||
|
||||
let name = '';
|
||||
|
@ -41,7 +41,7 @@ export default class Score_Hist extends Command {
|
|||
}
|
||||
}
|
||||
if (!user) return this.error(message.channel, 'Member not found.');
|
||||
const hists = await this.client.db.ScoreHistorical.find({ userID: user.id }).lean().exec();
|
||||
const hists = await this.client.db.mongo.ScoreHistorical.find({ userID: user.id }).lean().exec();
|
||||
if (!hists) return this.error(message.channel, 'No history found.');
|
||||
if (hists.length < 1) return this.error(message.channel, 'No history found.');
|
||||
const totalArray: number[] = [];
|
||||
|
|
|
@ -16,15 +16,15 @@ export default class Score_Notify extends Command {
|
|||
try {
|
||||
const user = message.author;
|
||||
if (!user) return this.error(message.channel, 'Member not found.');
|
||||
const score = await this.client.db.Score.findOne({ userID: message.author.id });
|
||||
const score = await this.client.db.mongo.Score.findOne({ userID: message.author.id });
|
||||
if (!score) return this.error(message.channel, 'Score not calculated yet.');
|
||||
if (!score.notify) await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
|
||||
if (!score.notify) await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
|
||||
switch (args[0]) {
|
||||
case 'on':
|
||||
await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: true } });
|
||||
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { notify: true } });
|
||||
return this.success(message.channel, 'You will now be sent notifications whenever your score is hard-pulled.');
|
||||
case 'off':
|
||||
await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
|
||||
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
|
||||
return this.success(message.channel, 'You will no longer be sent notifications when your score is hard-pulled.');
|
||||
default:
|
||||
return this.error(message.channel, 'Invalid option. Valid options are `on` and `off`.');
|
||||
|
|
|
@ -15,15 +15,15 @@ export default class Score_Pref extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!message.author) return this.error(message.channel, 'Member not found.');
|
||||
const score = await this.client.db.Score.findOne({ userID: message.author.id });
|
||||
const score = await this.client.db.mongo.Score.findOne({ userID: message.author.id });
|
||||
if (!score) return this.error(message.channel, 'Score not calculated yet.');
|
||||
if (!score.locked) await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } });
|
||||
if (!score.locked) await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } });
|
||||
switch (args[0]) {
|
||||
case 'lock':
|
||||
await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { locked: true } });
|
||||
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { locked: true } });
|
||||
return this.success(message.channel, 'Your report is now locked.');
|
||||
case 'unlock':
|
||||
await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } });
|
||||
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } });
|
||||
return this.success(message.channel, 'Your report is now unlocked.');
|
||||
default:
|
||||
return this.error(message.channel, 'Invalid input');
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class SIP extends Command {
|
|||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id });
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id });
|
||||
if (!staff || !staff?.extension) return this.error(message.channel, 'You must have an extension to complete this action.');
|
||||
this.success(message.channel, 'Queued call.');
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class SSS_Create_Account extends Command {
|
|||
|
||||
public async run(message: Message) {
|
||||
try {
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Staff information not located.');
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class SSS_Password_Reset extends Command {
|
|||
|
||||
public async run(message: Message) {
|
||||
try {
|
||||
const staff = await this.client.db.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!staff) return this.error(message.channel, 'Staff information not located.');
|
||||
|
||||
const passwordTicket = await this.client.util.authClient.createPasswordChangeTicket({
|
||||
|
|
|
@ -14,10 +14,10 @@ export default class Stats extends Command {
|
|||
|
||||
public async run(message: Message) {
|
||||
try {
|
||||
const messages = await this.client.db.Stat.findOne({ name: 'messages' });
|
||||
const commands = await this.client.db.Stat.findOne({ name: 'commands' });
|
||||
const pages = await this.client.db.Stat.findOne({ name: 'pages' });
|
||||
const requests = await this.client.db.Stat.findOne({ name: 'requests' });
|
||||
const messages = await this.client.db.mongo.Stat.findOne({ name: 'messages' });
|
||||
const commands = await this.client.db.mongo.Stat.findOne({ name: 'commands' });
|
||||
const pages = await this.client.db.mongo.Stat.findOne({ name: 'pages' });
|
||||
const requests = await this.client.db.mongo.Stat.findOne({ name: 'requests' });
|
||||
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Statistics');
|
||||
|
|
|
@ -33,7 +33,7 @@ export default class StoreMessages extends Command {
|
|||
const identifier = randomBytes(20).toString('hex');
|
||||
|
||||
const comp = await LocalStorage.compress(html);
|
||||
const file = new this.client.db.File({
|
||||
const file = new this.client.db.mongo.File({
|
||||
name: `${chan.name}-${new Date().toLocaleString('en-us')}.html.gz`,
|
||||
identifier,
|
||||
mimeType: 'application/gzip',
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class Unmute extends Command {
|
|||
if (!member) return this.error(message.channel, 'Cannot find user.');
|
||||
|
||||
try {
|
||||
const res1 = await this.client.db.local.muted.get<boolean>(`muted-${member.id}`);
|
||||
const res1 = await this.client.db.mongo.local.muted.get<boolean>(`muted-${member.id}`);
|
||||
if (!res1 || !this.mainGuild.members.get(member.id).roles.includes('478373942638149643')) return this.error(message.channel, 'This user is already unmuted.');
|
||||
} catch {} // eslint-disable-line no-empty
|
||||
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');
|
||||
|
|
|
@ -3,7 +3,6 @@ import moment from 'moment';
|
|||
import { Message, Member } from 'eris';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
import { whois as emotes } from '../configs/emotes.json';
|
||||
import { profile } from '.';
|
||||
|
||||
export default class Whois extends Command {
|
||||
constructor(client: Client) {
|
||||
|
@ -43,7 +42,7 @@ export default class Whois extends Command {
|
|||
}
|
||||
const embed = new RichEmbed();
|
||||
embed.setThumbnail(member.avatarURL);
|
||||
const ackResolve = await this.client.db.Staff.findOne({ userID: member.id }).lean().exec();
|
||||
const ackResolve = await this.client.db.mongo.Staff.findOne({ userID: member.id }).lean().exec();
|
||||
const mpn = this.memberPostNominals(member);
|
||||
let title = `${member.user.username}#${member.user.discriminator}`;
|
||||
if (!ackResolve && mpn) {
|
||||
|
@ -63,14 +62,14 @@ export default class Whois extends Command {
|
|||
if (ackResolve?.emailAddress) {
|
||||
description += `${emotes.email} ${ackResolve.emailAddress}\n`;
|
||||
}
|
||||
const pager = await this.client.db.PagerNumber.findOne({ individualAssignID: member.user.id }).lean().exec();
|
||||
const pager = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: member.user.id }).lean().exec();
|
||||
if (pager?.num) {
|
||||
description += `📟 ${pager.num}\n`;
|
||||
}
|
||||
if (ackResolve?.extension) {
|
||||
description += `☎️ ${ackResolve.extension}\n`;
|
||||
}
|
||||
const memberProfile = await this.client.db.Member.findOne({ userID: member.id }).lean().exec();
|
||||
const memberProfile = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec();
|
||||
if (memberProfile?.additional?.gitlab) {
|
||||
description += `${emotes.gitlab} ${memberProfile?.additional.gitlab}\n`;
|
||||
}
|
||||
|
@ -92,7 +91,7 @@ export default class Whois extends Command {
|
|||
embed.addField('Status', member.status === 'dnd' ? 'Do Not Disturb' : this.client.util.capsFirstLetter(member.status) || 'Offline', true);
|
||||
embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
||||
embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
||||
const score = await this.client.db.Score.findOne({ userID: member.id }).lean().exec();
|
||||
const score = await this.client.db.mongo.Score.findOne({ userID: member.id }).lean().exec();
|
||||
if (score) {
|
||||
await this.client.report.createInquiry(member.id, 'Library of Code sp-us | Bureau of Community Reports', 1);
|
||||
let totalScore = '0';
|
||||
|
@ -138,7 +137,7 @@ export default class Whois extends Command {
|
|||
if (bit & 2) permissions.push('Kick Members');
|
||||
|
||||
|
||||
const account = await this.client.db.Member.findOne({ userID: member.id }).lean().exec();
|
||||
const account = await this.client.db.mongo.Member.findOne({ userID: member.id }).lean().exec();
|
||||
if (account?.additional?.langs?.length > 0) {
|
||||
const langs: string[] = [];
|
||||
for (const lang of account.additional.langs.sort((a, b) => a.localeCompare(b))) {
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class X509 extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
const profile = await this.client.db.Member.findOne({ userID: args[0] || message.author.id });
|
||||
const profile = await this.client.db.mongo.Member.findOne({ userID: args[0] || message.author.id });
|
||||
if (!profile) return this.error(message.channel, 'Unable to find specified member\'s account.');
|
||||
const embed = new RichEmbed()
|
||||
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL())
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class X509_Remove extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message) {
|
||||
const profile = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
const profile = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
|
||||
if (!profile?.x509) return this.error(message.channel, 'There are no X.509 certificates connected to your account.');
|
||||
await profile.updateOne({ $unset: { x509: '' } });
|
||||
this.success(message.channel, 'Unlinked X.509 certificate from your account.');
|
||||
|
|
|
@ -16,8 +16,8 @@ export default class X509_Upload extends Command {
|
|||
|
||||
public async run(message: Message) {
|
||||
if (!message.attachments.length) return this.error(message.channel, 'Please upload your x509 certificate as an attachment.');
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.mongo.Member.create({ userID: message.author.id });
|
||||
}
|
||||
const [x509Attachment] = message.attachments;
|
||||
const x509Req: AxiosResponse<string> = await axios(x509Attachment.url);
|
||||
|
@ -27,7 +27,7 @@ export default class X509_Upload extends Command {
|
|||
} catch {
|
||||
return this.error(message.channel, 'Unable to parse your x509 certificate.');
|
||||
}
|
||||
await this.client.db.Member.updateOne({ userID: message.author.id }, { x509 });
|
||||
await this.client.db.mongo.Member.updateOne({ userID: message.author.id }, { x509 });
|
||||
this.success(message.channel, 'x509 certificate successfully uploaded to your account.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class CommandHandler extends Event {
|
|||
|
||||
public async run(message: Message) {
|
||||
try {
|
||||
this.client.db.Stat.updateOne({ name: 'messages' }, { $inc: { value: 1 } }).exec();
|
||||
this.client.db.mongo.Stat.updateOne({ name: 'messages' }, { $inc: { value: 1 } }).exec();
|
||||
if (message.author.bot) return;
|
||||
if (message.content.indexOf(this.client.config.prefix) !== 0) return;
|
||||
const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g);
|
||||
|
@ -26,7 +26,7 @@ export default class CommandHandler extends Event {
|
|||
}
|
||||
this.client.util.signale.log(`User '${message.author.username}#${message.author.discriminator}' ran command '${resolved.cmd.name}' in '${message.channel.id}'.`);
|
||||
await resolved.cmd.run(message, resolved.args);
|
||||
this.client.db.Stat.updateOne({ name: 'commands' }, { $inc: { value: 1 } }).exec();
|
||||
this.client.db.mongo.Stat.updateOne({ name: 'commands' }, { $inc: { value: 1 } }).exec();
|
||||
} catch (err) {
|
||||
this.client.util.handleError(err, message);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class InteractionCommandHandler extends Event {
|
|||
if (!int.checkPermissions(this.client.util.resolveMember(interaction.member?.id, this.client.guilds.get(this.client.config.guildID)))) return;
|
||||
// this.client.util.signale.log(`User '${message.author.username}#${message.author.discriminator}' ran interaction '${resolved.cmd.name}' in '${message.channel.id}'.`);
|
||||
await int.run(interaction);
|
||||
this.client.db.Stat.updateOne({ name: 'commands' }, { $inc: { value: 1 } }).exec();
|
||||
this.client.db.mongo.Stat.updateOne({ name: 'commands' }, { $inc: { value: 1 } }).exec();
|
||||
} catch (err) {
|
||||
this.client.util.handleError(err);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class GuildMemberAdd extends Event {
|
|||
|
||||
public async run(_, member: Member) {
|
||||
try {
|
||||
const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`);
|
||||
const search = await this.client.db.mongo.local.muted.get<boolean>(`muted-${member.user.id}`);
|
||||
if (search === true) {
|
||||
member.addRole('478373942638149643', 'muted user left server and joined back');
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ export default class MessageReactionAdd extends Event {
|
|||
|
||||
if (!reactor.roles.includes(this.directorRole)) return;
|
||||
|
||||
const proc = await this.client.db.Proclamation.findOne({ msg: message.id, processed: false });
|
||||
const proc = await this.client.db.mongo.Proclamation.findOne({ msg: message.id, processed: false });
|
||||
|
||||
if (!proc?.votedDirectors.includes(reactor.id)) {
|
||||
let type: 'yea' | 'nay' | 'present';
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable no-undef */
|
||||
import { TextChannel } from 'eris';
|
||||
import { Client, RichEmbed } from '../class';
|
||||
import { MemberInterface } from '../models';
|
||||
import { CloudServicesUtil } from '../util';
|
||||
|
||||
let interval: NodeJS.Timeout;
|
||||
|
@ -9,10 +8,10 @@ let interval: NodeJS.Timeout;
|
|||
export default async function checkLock(client: Client) {
|
||||
async function start() {
|
||||
try {
|
||||
const moderations = await client.db.Moderation.find();
|
||||
const judgements = await client.db.Judgement.find().lean().exec();
|
||||
const members = await client.db.Member.find();
|
||||
members.forEach(async (member: MemberInterface) => {
|
||||
const moderations = await client.db.mongo.Moderation.find();
|
||||
const judgements = await client.db.mongo.Judgement.find().lean().exec();
|
||||
const members = await client.db.mongo.Member.find();
|
||||
members.forEach(async (member: typeof members[0]) => {
|
||||
if (member.misc?.t3TemporaryExpiration && member.misc.t3TemporaryExpiration.processed === false) {
|
||||
if (new Date() > member.misc.t3TemporaryExpiration.date) {
|
||||
await CloudServicesUtil.setTier(member.userID, member.misc.t3TemporaryExpiration.previousTier, client.config.internalKey);
|
||||
|
@ -23,7 +22,7 @@ export default async function checkLock(client: Client) {
|
|||
judgements.forEach(async (judgement) => {
|
||||
if (!judgement.expires) return;
|
||||
if (new Date() > judgement.expires) {
|
||||
await client.db.Judgement.deleteOne(({ _id: judgement._id }));
|
||||
await client.db.mongo.Judgement.deleteOne(({ _id: judgement._id }));
|
||||
const log = <TextChannel> client.guilds.get(client.config.guildID).channels.get('611584771356622849');
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Judgement - Rescind');
|
||||
|
|
|
@ -6,15 +6,15 @@ import { Client } from '../class';
|
|||
let interval: NodeJS.Timeout;
|
||||
|
||||
async function setupDepartmentCodes(client: Client): Promise<void> {
|
||||
const directorPagers = await client.db.PagerNumber.findOne({ num: '00' }).lean().exec();
|
||||
const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' }).lean().exec();
|
||||
const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' }).lean().exec();
|
||||
const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' }).lean().exec();
|
||||
const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' }).lean().exec();
|
||||
const associatePagers = await client.db.PagerNumber.findOne({ num: '22' }).lean().exec();
|
||||
const directorPagers = await client.db.mongo.PagerNumber.findOne({ num: '00' }).lean().exec();
|
||||
const supervisorPagers = await client.db.mongo.PagerNumber.findOne({ num: '01' }).lean().exec();
|
||||
const technicianPagers = await client.db.mongo.PagerNumber.findOne({ num: '10' }).lean().exec();
|
||||
const moderatorPagers = await client.db.mongo.PagerNumber.findOne({ num: '20' }).lean().exec();
|
||||
const coreTeamPagers = await client.db.mongo.PagerNumber.findOne({ num: '21' }).lean().exec();
|
||||
const associatePagers = await client.db.mongo.PagerNumber.findOne({ num: '22' }).lean().exec();
|
||||
|
||||
if (!directorPagers) {
|
||||
const setup = new client.db.PagerNumber({
|
||||
const setup = new client.db.mongo.PagerNumber({
|
||||
num: '00',
|
||||
individualAssignID: '',
|
||||
emailAddresses: [],
|
||||
|
@ -23,7 +23,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
|
|||
await setup.save();
|
||||
}
|
||||
if (!supervisorPagers) {
|
||||
const setup = new client.db.PagerNumber({
|
||||
const setup = new client.db.mongo.PagerNumber({
|
||||
num: '01',
|
||||
individualAssignID: '',
|
||||
emailAddresses: [],
|
||||
|
@ -32,7 +32,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
|
|||
await setup.save();
|
||||
}
|
||||
if (!technicianPagers) {
|
||||
const setup = new client.db.PagerNumber({
|
||||
const setup = new client.db.mongo.PagerNumber({
|
||||
num: '10',
|
||||
individualAssignID: '',
|
||||
emailAddresses: [],
|
||||
|
@ -41,7 +41,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
|
|||
setup.save();
|
||||
}
|
||||
if (!moderatorPagers) {
|
||||
const setup = new client.db.PagerNumber({
|
||||
const setup = new client.db.mongo.PagerNumber({
|
||||
num: '20',
|
||||
individualAssignID: '',
|
||||
emailAddresses: [],
|
||||
|
@ -50,7 +50,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
|
|||
await setup.save();
|
||||
}
|
||||
if (!coreTeamPagers) {
|
||||
const setup = new client.db.PagerNumber({
|
||||
const setup = new client.db.mongo.PagerNumber({
|
||||
num: '21',
|
||||
individualAssignID: '',
|
||||
emailAddresses: [],
|
||||
|
@ -59,7 +59,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
|
|||
await setup.save();
|
||||
}
|
||||
if (!associatePagers) {
|
||||
const setup = new client.db.PagerNumber({
|
||||
const setup = new client.db.mongo.PagerNumber({
|
||||
num: '22',
|
||||
individualAssignID: '',
|
||||
emailAddresses: [],
|
||||
|
@ -80,46 +80,46 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
// eslint-disable-next-line no-shadow
|
||||
async function start(client: Client) {
|
||||
async function resolveStaffInformation(id: string) {
|
||||
return client.db.Staff.findOne({ userID: id }); // acknowledgements.find((m) => m.id === id);
|
||||
return client.db.mongo.Staff.findOne({ userID: id }); // acknowledgements.find((m) => m.id === id);
|
||||
}
|
||||
await client.guilds.get(client.config.guildID).fetchAllMembers();
|
||||
const members = client.guilds.get(client.config.guildID).members.map((m) => m);
|
||||
|
||||
for (const member of members) {
|
||||
const pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
|
||||
const pager = await client.db.mongo.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
|
||||
if (!pager) continue;
|
||||
if (pager.num.startsWith('00') && !member.roles.includes('662163685439045632')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.db.mongo.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('01') && !member.roles.includes('701454855952138300')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.db.mongo.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('10') && !member.roles.includes('701454780828221450')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.db.mongo.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('20') && !member.roles.includes('455972169449734144')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.db.mongo.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('21') && !member.roles.includes('453689940140883988')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.db.mongo.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('22') && !member.roles.includes('701481967149121627')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.db.mongo.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
|
@ -127,7 +127,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
|
||||
for (const member of members) {
|
||||
let pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
|
||||
let pager = await client.db.mongo.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
|
||||
|
||||
// ADD TO ALL STAFF MAILING LIST
|
||||
if ((member.roles.includes('453689940140883988') || member.roles.includes('701481967149121627')) && !pager) {
|
||||
|
@ -141,19 +141,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
// eslint-disable-next-line no-constant-condition
|
||||
while (status) {
|
||||
randomPagerNumber = `00${String(Math.floor(Math.random() * 9) + 1)}`;
|
||||
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
const check = await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
if (check) status = false;
|
||||
if (check?.num !== randomPagerNumber) status = false;
|
||||
}
|
||||
const acknowledgement = await resolveStaffInformation(member.id);
|
||||
if (!acknowledgement || !acknowledgement.emailAddress) continue;
|
||||
const newNumber = new client.db.PagerNumber({
|
||||
const newNumber = new client.db.mongo.PagerNumber({
|
||||
num: randomPagerNumber,
|
||||
individualAssignID: member.id,
|
||||
emailAddresses: [acknowledgement.emailAddress],
|
||||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
if (await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
|
||||
const channel: PrivateChannel = await client.getDMChannel(member.id);
|
||||
|
@ -186,19 +186,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
// eslint-disable-next-line no-constant-condition
|
||||
while (status) {
|
||||
randomPagerNumber = `01${String(Math.floor(Math.random() * 9) + 1)}`;
|
||||
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
const check = await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
if (check) status = false;
|
||||
if (check?.num !== randomPagerNumber) status = false;
|
||||
}
|
||||
const acknowledgement = await resolveStaffInformation(member.id);
|
||||
if (!acknowledgement || !acknowledgement.emailAddress) continue;
|
||||
const newNumber = new client.db.PagerNumber({
|
||||
const newNumber = new client.db.mongo.PagerNumber({
|
||||
num: randomPagerNumber,
|
||||
individualAssignID: member.id,
|
||||
emailAddresses: [acknowledgement.emailAddress],
|
||||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
if (await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
|
||||
const channel: PrivateChannel = await client.getDMChannel(member.id);
|
||||
|
@ -232,19 +232,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
while (status) {
|
||||
randomPagerNumber = `10${String(Math.floor(Math.random() * 99) + 1)}`;
|
||||
if (randomPagerNumber.length === 3) randomPagerNumber = `${randomPagerNumber}0`;
|
||||
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
const check = await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
if (check) status = false;
|
||||
if (check?.num !== randomPagerNumber) status = false;
|
||||
}
|
||||
const acknowledgement = await resolveStaffInformation(member.id);
|
||||
if (!acknowledgement || !acknowledgement.emailAddress) continue;
|
||||
const newNumber = new client.db.PagerNumber({
|
||||
const newNumber = new client.db.mongo.PagerNumber({
|
||||
num: randomPagerNumber,
|
||||
individualAssignID: member.id,
|
||||
emailAddresses: [acknowledgement.emailAddress],
|
||||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
if (await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
|
||||
const channel: PrivateChannel = await client.getDMChannel(member.id);
|
||||
|
@ -278,19 +278,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
while (status) {
|
||||
randomPagerNumber = `20${String(Math.floor(Math.random() * 99) + 1)}`;
|
||||
if (randomPagerNumber.length === 3) randomPagerNumber = `${randomPagerNumber}0`;
|
||||
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
const check = await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
if (check) status = false;
|
||||
if (check?.num !== randomPagerNumber) status = false;
|
||||
}
|
||||
const acknowledgement = await resolveStaffInformation(member.id);
|
||||
if (!acknowledgement || !acknowledgement.emailAddress) continue;
|
||||
const newNumber = new client.db.PagerNumber({
|
||||
const newNumber = new client.db.mongo.PagerNumber({
|
||||
num: randomPagerNumber,
|
||||
individualAssignID: member.id,
|
||||
emailAddresses: [acknowledgement.emailAddress],
|
||||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
if (await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
|
||||
const channel: PrivateChannel = await client.getDMChannel(member.id);
|
||||
|
@ -324,19 +324,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
while (status) {
|
||||
randomPagerNumber = `21${String(Math.floor(Math.random() * 999) + 1)}`;
|
||||
if (randomPagerNumber.length === 4) randomPagerNumber = `${randomPagerNumber}0`;
|
||||
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
const check = await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
if (check) status = false;
|
||||
if (check?.num !== randomPagerNumber) status = false;
|
||||
}
|
||||
const acknowledgement = await resolveStaffInformation(member.id);
|
||||
if (!acknowledgement || !acknowledgement.emailAddress) continue;
|
||||
const newNumber = new client.db.PagerNumber({
|
||||
const newNumber = new client.db.mongo.PagerNumber({
|
||||
num: randomPagerNumber,
|
||||
individualAssignID: member.id,
|
||||
emailAddresses: [acknowledgement.emailAddress],
|
||||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
if (await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
|
||||
const channel: PrivateChannel = await client.getDMChannel(member.id);
|
||||
|
@ -370,19 +370,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
while (status) {
|
||||
randomPagerNumber = `22${String(Math.floor(Math.random() * 999) + 1)}`;
|
||||
if (randomPagerNumber.length === 4) randomPagerNumber = `${randomPagerNumber}0`;
|
||||
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
const check = await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber });
|
||||
if (check) status = false;
|
||||
if (check?.num !== randomPagerNumber) status = false;
|
||||
}
|
||||
const acknowledgement = await resolveStaffInformation(member.id);
|
||||
if (!acknowledgement || !acknowledgement.emailAddress) continue;
|
||||
const newNumber = new client.db.PagerNumber({
|
||||
const newNumber = new client.db.mongo.PagerNumber({
|
||||
num: randomPagerNumber,
|
||||
individualAssignID: member.id,
|
||||
emailAddresses: [acknowledgement.emailAddress],
|
||||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
if (await client.db.mongo.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
|
||||
const channel: PrivateChannel = await client.getDMChannel(member.id);
|
||||
|
@ -412,7 +412,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
|
||||
// Associates
|
||||
const associatePagers = await client.db.PagerNumber.findOne({ num: '22' });
|
||||
const associatePagers = await client.db.mongo.PagerNumber.findOne({ num: '22' });
|
||||
for (const member of members) {
|
||||
if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) {
|
||||
await associatePagers.updateOne({ $addToSet: { discordIDs: member.id } });
|
||||
|
@ -426,7 +426,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
}
|
||||
// Core Team
|
||||
const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' });
|
||||
const coreTeamPagers = await client.db.mongo.PagerNumber.findOne({ num: '21' });
|
||||
for (const member of members) {
|
||||
if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) {
|
||||
await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } });
|
||||
|
@ -440,7 +440,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
}
|
||||
// Moderator
|
||||
const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' });
|
||||
const moderatorPagers = await client.db.mongo.PagerNumber.findOne({ num: '20' });
|
||||
for (const member of members) {
|
||||
if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) {
|
||||
await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
|
||||
|
@ -454,7 +454,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
}
|
||||
// Technician
|
||||
const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' });
|
||||
const technicianPagers = await client.db.mongo.PagerNumber.findOne({ num: '10' });
|
||||
for (const member of members) {
|
||||
if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) {
|
||||
await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } });
|
||||
|
@ -468,7 +468,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
}
|
||||
// Supervisor
|
||||
const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' });
|
||||
const supervisorPagers = await client.db.mongo.PagerNumber.findOne({ num: '01' });
|
||||
for (const member of members) {
|
||||
if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) {
|
||||
await supervisorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
|
||||
|
@ -482,7 +482,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
}
|
||||
}
|
||||
// Board of Directors
|
||||
const directorPagers = await client.db.PagerNumber.findOne({ num: '00' });
|
||||
const directorPagers = await client.db.mongo.PagerNumber.findOne({ num: '00' });
|
||||
for (const member of members) {
|
||||
if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) {
|
||||
await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
|
||||
|
|
|
@ -40,7 +40,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
}
|
||||
for (const member of members.values()) {
|
||||
if (member.bot) continue;
|
||||
let score = await client.db.Score.findOne({ userID: member.user.id });
|
||||
let score = await client.db.mongo.Score.findOne({ userID: member.user.id });
|
||||
if (!score) {
|
||||
const data: {
|
||||
userID: string,
|
||||
|
@ -69,7 +69,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
lastUpdated: new Date(),
|
||||
pin: [client.util.randomNumber(100, 999), client.util.randomNumber(10, 99), client.util.randomNumber(1000, 9999)],
|
||||
};
|
||||
score = await (new client.db.Score(data)).save();
|
||||
score = await (new client.db.mongo.Score(data)).save();
|
||||
client.util.signale.debug(`SCORE INIT - ${member.username}`);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
roles = Math.floor(member.roles.length * 0.50);
|
||||
if (roles > 54) roles = 54;
|
||||
|
||||
const moderations = await client.db.Moderation.find({ userID: member.user.id });
|
||||
const moderations = await client.db.mongo.Moderation.find({ userID: member.user.id });
|
||||
let activeMods = 0;
|
||||
for (const mod of moderations) {
|
||||
if (mod.type === 1 || mod.type === 4) continue;
|
||||
|
@ -146,8 +146,8 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
else cloudServices = Math.floor(positives * 0.61);
|
||||
}
|
||||
|
||||
const inquiries = await client.db.Inquiry.find({ userID: member.user.id, type: 0 }).lean().exec();
|
||||
const judgements = await client.db.Judgement.find({ userID: member.user.id }).lean().exec();
|
||||
const inquiries = await client.db.mongo.Inquiry.find({ userID: member.user.id, type: 0 }).lean().exec();
|
||||
const judgements = await client.db.mongo.Judgement.find({ userID: member.user.id }).lean().exec();
|
||||
|
||||
if (inquiries?.length > 0) {
|
||||
for (const inq of inquiries) {
|
||||
|
@ -189,9 +189,9 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
|
||||
// client.queue.updateScore(score, total, activity, roles, moderation, cloudServices, other, staff);
|
||||
|
||||
client.db.Score.updateOne({ userID: score.userID }, { $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } }).exec();
|
||||
client.db.mongo.Score.updateOne({ userID: score.userID }, { $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } }).exec();
|
||||
if (!score.pin || score.pin?.length < 1) {
|
||||
client.db.Score.updateOne({ userID: score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } }).exec();
|
||||
client.db.mongo.Score.updateOne({ userID: score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } }).exec();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface CustomerInterface extends Document {
|
||||
cusID: string,
|
||||
userID: string,
|
||||
}
|
||||
|
||||
const Customer: Schema = new Schema({
|
||||
cusID: String,
|
||||
userID: String,
|
||||
});
|
||||
|
||||
export default model<CustomerInterface>('Customer', Customer);
|
|
@ -1,21 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface CustomerPortalInterface extends Document {
|
||||
key: string,
|
||||
username: string,
|
||||
userID: string,
|
||||
emailAddress: string,
|
||||
expiresOn: Date,
|
||||
used?: boolean,
|
||||
}
|
||||
|
||||
const CustomerPortal: Schema = new Schema({
|
||||
key: String,
|
||||
username: String,
|
||||
userID: String,
|
||||
emailAddress: String,
|
||||
expiresOn: Date,
|
||||
used: Boolean,
|
||||
});
|
||||
|
||||
export default model<CustomerPortalInterface>('CustomerPortal', CustomerPortal);
|
|
@ -1,21 +0,0 @@
|
|||
import { Document, model, Schema } from 'mongoose';
|
||||
|
||||
export interface ExecutiveOrderInterface extends Document {
|
||||
issuer: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
at: number;
|
||||
oID: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
const ExecutiveOrder = new Schema({
|
||||
issuer: { type: String, required: true },
|
||||
subject: { type: String, required: true },
|
||||
body: { type: String, required: true },
|
||||
at: { type: Number, required: true },
|
||||
oID: { type: String, required: true, unique: true },
|
||||
msg: { type: String, required: true, unique: true },
|
||||
});
|
||||
|
||||
export default model<ExecutiveOrderInterface>('ExecutiveOrders', ExecutiveOrder);
|
|
@ -1,21 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface FileInterface extends Document {
|
||||
name: string,
|
||||
identifier: string,
|
||||
mimeType: string,
|
||||
data: Buffer,
|
||||
downloaded: number,
|
||||
maxDownloads: number,
|
||||
}
|
||||
|
||||
const File: Schema = new Schema({
|
||||
name: String,
|
||||
identifier: String,
|
||||
mimeType: String,
|
||||
data: Buffer,
|
||||
downloaded: Number,
|
||||
maxDownloads: Number,
|
||||
});
|
||||
|
||||
export default model<FileInterface>('File', File);
|
|
@ -1,33 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
import { ScoreInterfaceRaw } from '.';
|
||||
|
||||
export enum InqType {
|
||||
HARD,
|
||||
SOFT,
|
||||
}
|
||||
|
||||
export interface InquiryInterface extends Document {
|
||||
iid?: string,
|
||||
userID: string,
|
||||
/**
|
||||
* - 0: Hard
|
||||
* - 1: Soft
|
||||
*/
|
||||
type: InqType,
|
||||
name: string,
|
||||
reason?: string,
|
||||
date: Date,
|
||||
report?: ScoreInterfaceRaw,
|
||||
}
|
||||
|
||||
const Inquiry: Schema = new Schema({
|
||||
iid: String,
|
||||
userID: String,
|
||||
type: Number,
|
||||
name: String,
|
||||
reason: String,
|
||||
date: String,
|
||||
report: Object,
|
||||
});
|
||||
|
||||
export default model<InquiryInterface>('Inquiry', Inquiry);
|
|
@ -1,35 +0,0 @@
|
|||
/* eslint-disable no-shadow */
|
||||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
enum Severity {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
}
|
||||
|
||||
export interface JudgementInterface extends Document {
|
||||
jid: string,
|
||||
userID: string,
|
||||
enteredBy: string,
|
||||
/**
|
||||
* - 0: LOW
|
||||
* - 1: MEDIUM
|
||||
* - 2: HIGH
|
||||
*/
|
||||
severity: Severity,
|
||||
date: Date,
|
||||
expires: Date | null | undefined,
|
||||
description: string,
|
||||
}
|
||||
|
||||
const Judgement: Schema = new Schema({
|
||||
jid: String,
|
||||
userID: String,
|
||||
enteredBy: String,
|
||||
severity: Number,
|
||||
date: Date,
|
||||
expires: Date,
|
||||
description: String,
|
||||
});
|
||||
|
||||
export default model<JudgementInterface>('Judgement', Judgement);
|
|
@ -1,43 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface MemberInterface extends Document {
|
||||
userID: string,
|
||||
additional?: {
|
||||
langs: ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'],
|
||||
operatingSystems: ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'],
|
||||
github: string,
|
||||
gitlab: string,
|
||||
bio: string,
|
||||
},
|
||||
misc?: {
|
||||
t3TemporaryExpiration?: {
|
||||
date: Date,
|
||||
processed: boolean
|
||||
previousTier: 1 | 2 | 3
|
||||
}
|
||||
}
|
||||
x509?: string,
|
||||
pgp?: string,
|
||||
}
|
||||
|
||||
const Member: Schema = new Schema({
|
||||
userID: String,
|
||||
additional: {
|
||||
langs: Array,
|
||||
operatingSystems: Array,
|
||||
github: String,
|
||||
gitlab: String,
|
||||
bio: String,
|
||||
},
|
||||
misc: {
|
||||
t3TemporaryExpiration: {
|
||||
date: Date,
|
||||
processed: Boolean,
|
||||
previousTier: Number,
|
||||
},
|
||||
},
|
||||
x509: String,
|
||||
pgp: String,
|
||||
});
|
||||
|
||||
export default model<MemberInterface>('Member', Member);
|
|
@ -1,24 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface MerchantInterface extends Document {
|
||||
name: string,
|
||||
key: string,
|
||||
privileged: boolean,
|
||||
/**
|
||||
* type
|
||||
* - 0: soft
|
||||
* - 1: hard
|
||||
*/
|
||||
type: 0 | 1;
|
||||
pulls: [{ type: 0 | 1, reason: string, date: Date }],
|
||||
}
|
||||
|
||||
const Merchant: Schema = new Schema({
|
||||
name: String,
|
||||
key: String,
|
||||
privileged: Boolean,
|
||||
type: Number,
|
||||
pulls: Array,
|
||||
});
|
||||
|
||||
export default model<MerchantInterface>('Merchant', Merchant);
|
|
@ -1,37 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface ModerationInterface extends Document {
|
||||
userID: string,
|
||||
logID: string,
|
||||
moderatorID: string,
|
||||
reason: string,
|
||||
/**
|
||||
* @field 0 - Warn
|
||||
* @field 1 - Unmute
|
||||
* @field 2 - Mute
|
||||
* @field 3 - Kick
|
||||
* @field 4 - Unban
|
||||
* @field 5 - Ban
|
||||
*/
|
||||
type: 0 | 1 | 2 | 3 | 4 | 5
|
||||
date: Date,
|
||||
expiration?: {
|
||||
date: Date,
|
||||
processed: boolean
|
||||
}
|
||||
}
|
||||
|
||||
const Moderation: Schema = new Schema({
|
||||
userID: String,
|
||||
logID: String,
|
||||
moderatorID: String,
|
||||
reason: String,
|
||||
type: Number,
|
||||
date: Date,
|
||||
expiration: {
|
||||
date: Date,
|
||||
processed: Boolean,
|
||||
},
|
||||
});
|
||||
|
||||
export default model<ModerationInterface>('Moderation', Moderation);
|
|
@ -1,35 +0,0 @@
|
|||
import { Document, model, Schema } from 'mongoose';
|
||||
|
||||
export interface MotionInterface extends Document {
|
||||
issuer: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
at: number;
|
||||
oID: string;
|
||||
results?: {
|
||||
yea: number;
|
||||
nay: number;
|
||||
present: number;
|
||||
absent: number;
|
||||
};
|
||||
processed: boolean;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
const Motion = new Schema({
|
||||
issuer: { type: String, required: true },
|
||||
subject: { type: String, required: true },
|
||||
body: { type: String, required: true },
|
||||
at: { type: Number, required: true },
|
||||
oID: { type: String, required: true, unique: true },
|
||||
results: {
|
||||
yea: Number,
|
||||
nay: Number,
|
||||
present: Number,
|
||||
absent: Number,
|
||||
},
|
||||
processed: Boolean,
|
||||
msg: { required: true, unique: true, type: String },
|
||||
});
|
||||
|
||||
export default model<MotionInterface>('Motions', Motion);
|
|
@ -1,19 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface NoteInterface extends Document {
|
||||
userID: string,
|
||||
staffID: string,
|
||||
date: Date,
|
||||
category: 'comm' | 'cs' | 'edu' | '',
|
||||
text: string,
|
||||
}
|
||||
|
||||
const Note: Schema = new Schema({
|
||||
userID: String,
|
||||
staffID: String,
|
||||
date: Date,
|
||||
category: String,
|
||||
text: String,
|
||||
});
|
||||
|
||||
export default model<NoteInterface>('Note', Note);
|
|
@ -1,32 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface PagerNumberRaw {
|
||||
num: string,
|
||||
// This field will be "" if the pager number doesn't belong to an individual user
|
||||
individualAssignID: string,
|
||||
emailAddresses: string[],
|
||||
discordIDs: string[],
|
||||
receiveEmail: boolean,
|
||||
receivePhone: boolean,
|
||||
}
|
||||
|
||||
export interface PagerNumberInterface extends Document {
|
||||
num: string,
|
||||
// This field will be "" if the pager number doesn't belong to an individual user
|
||||
individualAssignID: string,
|
||||
emailAddresses: string[],
|
||||
discordIDs: string[],
|
||||
receiveEmail: boolean,
|
||||
receivePhone: boolean,
|
||||
}
|
||||
|
||||
const PagerNumber: Schema = new Schema({
|
||||
num: String,
|
||||
individualAssignID: String,
|
||||
emailAddresses: Array,
|
||||
discordIDs: Array,
|
||||
receiveEmail: Boolean,
|
||||
receivePhone: Boolean,
|
||||
});
|
||||
|
||||
export default model<PagerNumberInterface>('PagerNumber', PagerNumber);
|
|
@ -1,37 +0,0 @@
|
|||
import { Document, model, Schema } from 'mongoose';
|
||||
|
||||
export interface ProclamationInterface extends Document {
|
||||
issuer: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
at: number;
|
||||
oID: string;
|
||||
results?: {
|
||||
yea: number;
|
||||
nay: number;
|
||||
present: number;
|
||||
absent: number;
|
||||
};
|
||||
msg: string;
|
||||
processed?: boolean;
|
||||
votedDirectors: string[];
|
||||
}
|
||||
|
||||
const Proclamation = new Schema({
|
||||
issuer: { type: String, required: true },
|
||||
subject: { type: String, required: true },
|
||||
body: { type: String, required: true },
|
||||
at: { type: Number, required: true },
|
||||
oID: { type: String, required: true, unique: true },
|
||||
results: {
|
||||
yea: Number,
|
||||
nay: Number,
|
||||
present: Number,
|
||||
absent: Number,
|
||||
},
|
||||
msg: { type: String, required: true, unique: true },
|
||||
processed: Boolean,
|
||||
votedDirectors: { type: Array, required: true },
|
||||
});
|
||||
|
||||
export default model<ProclamationInterface>('Proclamations', Proclamation);
|
|
@ -1,13 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface PromoInterface extends Document {
|
||||
code: string,
|
||||
pID: string,
|
||||
}
|
||||
|
||||
const Promo: Schema = new Schema({
|
||||
code: String,
|
||||
pID: String,
|
||||
});
|
||||
|
||||
export default model<PromoInterface>('Promo', Promo);
|
|
@ -1,17 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface RankInterface extends Document {
|
||||
name: string,
|
||||
roleID: string,
|
||||
permissions: string[],
|
||||
description: string,
|
||||
}
|
||||
|
||||
const Rank: Schema = new Schema({
|
||||
name: String,
|
||||
roleID: String,
|
||||
permissions: Array,
|
||||
description: String,
|
||||
});
|
||||
|
||||
export default model<RankInterface>('Rank', Rank);
|
|
@ -1,21 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface RedirectInterface extends Document {
|
||||
key: string,
|
||||
to: string,
|
||||
visitedCount: number,
|
||||
}
|
||||
|
||||
export interface RedirectRaw {
|
||||
key: string,
|
||||
to: string,
|
||||
visitedCount: number,
|
||||
}
|
||||
|
||||
const Redirect: Schema = new Schema({
|
||||
key: String,
|
||||
to: String,
|
||||
visitedCount: Number,
|
||||
});
|
||||
|
||||
export default model<RedirectInterface>('Redirect', Redirect);
|
|
@ -1,33 +0,0 @@
|
|||
import { Document, model, Schema } from 'mongoose';
|
||||
|
||||
export interface ResolutionInterface extends Document {
|
||||
issuer: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
at: number;
|
||||
oID: string;
|
||||
results: {
|
||||
yea: number;
|
||||
nay: number;
|
||||
present: number;
|
||||
absent: number;
|
||||
};
|
||||
msg: string;
|
||||
}
|
||||
|
||||
const Resolution = new Schema({
|
||||
issuer: { type: String, required: true },
|
||||
subject: { type: String, required: true },
|
||||
body: { type: String, required: true },
|
||||
at: { type: Number, required: true },
|
||||
oID: { type: String, required: true, unique: true },
|
||||
results: {
|
||||
yea: Number,
|
||||
Nay: Number,
|
||||
present: Number,
|
||||
absent: Number,
|
||||
},
|
||||
msg: { type: String, required: true, unique: true },
|
||||
});
|
||||
|
||||
export default model<ResolutionInterface>('Resolutions', Resolution);
|
|
@ -1,17 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface SAAInterface extends Document {
|
||||
userID: string,
|
||||
applicationID: string,
|
||||
serviceCode: string,
|
||||
edsToken: string,
|
||||
}
|
||||
|
||||
const SAA: Schema = new Schema({
|
||||
userID: String,
|
||||
applicationID: String,
|
||||
serviceCode: String,
|
||||
edsToken: String,
|
||||
});
|
||||
|
||||
export default model<SAAInterface>('SAA', SAA);
|
|
@ -1,95 +0,0 @@
|
|||
// Community Score
|
||||
|
||||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface Inquiry {
|
||||
id?: string,
|
||||
name: string,
|
||||
reason: string,
|
||||
date: Date,
|
||||
report: ScoreInterfaceRaw,
|
||||
}
|
||||
|
||||
export interface ScoreInterfaceRaw {
|
||||
userID: string
|
||||
/**
|
||||
* total will be between 800-200 - 0 signfies "No Score", too little information is available or other variable are too low
|
||||
* - CALCULATION: `(COMBINED SUBSCORES x 5) * 5.13; Math.floor()`
|
||||
*/
|
||||
total: number,
|
||||
/**
|
||||
* 10 - 55
|
||||
*/
|
||||
activity: number,
|
||||
/**
|
||||
* 0 - 54
|
||||
*/
|
||||
roles: number,
|
||||
/**
|
||||
* -50 - 2
|
||||
* all users start out with 2 moderation points, the number of points decreases for each moderation.
|
||||
*/
|
||||
moderation: number,
|
||||
/**
|
||||
* -20 - 50
|
||||
* processed by CSD
|
||||
*/
|
||||
cloudServices: number,
|
||||
// 0 or 20, 20 points are added if the user is a staff member
|
||||
staff: number,
|
||||
other: number,
|
||||
notify: boolean,
|
||||
locked: boolean,
|
||||
inquiries: [ Inquiry ],
|
||||
softInquiries: [{ name: string, date: Date }],
|
||||
lastUpdate: Date,
|
||||
pin: number[],
|
||||
}
|
||||
|
||||
|
||||
export interface ScoreInterface extends Document {
|
||||
userID: string
|
||||
total: number,
|
||||
activity: number,
|
||||
roles: number,
|
||||
moderation: number,
|
||||
cloudServices: number,
|
||||
staff: number,
|
||||
other: number,
|
||||
notify: boolean,
|
||||
locked: boolean,
|
||||
inquiries: [ Inquiry ],
|
||||
softInquiries: [{ name: string, date: Date }],
|
||||
lastUpdate: Date,
|
||||
pin: number[],
|
||||
|
||||
// general & media
|
||||
/* generalMessagesRatio: number,
|
||||
// programming-support channels and cloud-support
|
||||
supportMessagesRatio: number,
|
||||
totalModerations: number,
|
||||
notes: number, */
|
||||
}
|
||||
|
||||
const Score: Schema = new Schema({
|
||||
userID: String,
|
||||
total: Number,
|
||||
activity: Number,
|
||||
roles: Number,
|
||||
moderation: Number,
|
||||
cloudServices: Number,
|
||||
staff: Number,
|
||||
other: Number,
|
||||
notify: Boolean,
|
||||
locked: Boolean,
|
||||
inquiries: Array,
|
||||
softInquiries: Array,
|
||||
lastUpdate: Date,
|
||||
pin: Array,
|
||||
/* generalMessagesRatio: Number,
|
||||
supportMessagesRatio: Number,
|
||||
totalModerations: Number,
|
||||
notes: Number, */
|
||||
});
|
||||
|
||||
export default model<ScoreInterface>('Score', Score);
|
|
@ -1,42 +0,0 @@
|
|||
import { Document, Schema, model, Types } from 'mongoose';
|
||||
|
||||
export interface ScoreHistoricalRaw {
|
||||
userID: string,
|
||||
report: {
|
||||
total: number,
|
||||
activity: number,
|
||||
roles: number,
|
||||
moderation: number,
|
||||
cloudServices: number,
|
||||
staff: number,
|
||||
other: number,
|
||||
},
|
||||
// inquiries: [ Types.ObjectId ],
|
||||
inquiries: Types.ObjectId[],
|
||||
date: Date,
|
||||
}
|
||||
|
||||
export interface ScoreHistoricalInterface extends Document {
|
||||
userID: string,
|
||||
report: {
|
||||
total: number,
|
||||
activity: number,
|
||||
roles: number,
|
||||
moderation: number,
|
||||
cloudServices: number,
|
||||
staff: number,
|
||||
other: number,
|
||||
},
|
||||
// inquiries: [ Types.ObjectId ],
|
||||
inquiries: Types.ObjectId[],
|
||||
date: Date
|
||||
}
|
||||
|
||||
const ScoreHistorical: Schema = new Schema({
|
||||
userID: String,
|
||||
report: Object,
|
||||
inquiries: Array,
|
||||
date: Date,
|
||||
});
|
||||
|
||||
export default model<ScoreHistoricalInterface>('ScoreHistorical', ScoreHistorical);
|
|
@ -1,27 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface StaffInterface extends Document {
|
||||
name: string,
|
||||
userID: string,
|
||||
title: string,
|
||||
dept: string,
|
||||
pn: string[],
|
||||
emailAddress: string,
|
||||
extension: string,
|
||||
acknowledgements: string[],
|
||||
additionalRoles: string[]
|
||||
}
|
||||
|
||||
const Staff: Schema = new Schema({
|
||||
name: String,
|
||||
userID: String,
|
||||
title: String,
|
||||
dept: String,
|
||||
pn: Array,
|
||||
emailAddress: String,
|
||||
extension: String,
|
||||
acknowledgements: Array,
|
||||
additionalRoles: Array,
|
||||
});
|
||||
|
||||
export default model<StaffInterface>('Staff', Staff);
|
|
@ -1,13 +0,0 @@
|
|||
import { Document, Schema, model } from 'mongoose';
|
||||
|
||||
export interface StatInterface extends Document {
|
||||
name: 'messages' | 'commands' | 'pages' | 'requests',
|
||||
value: number,
|
||||
}
|
||||
|
||||
const Stat: Schema = new Schema({
|
||||
name: String,
|
||||
value: Number,
|
||||
});
|
||||
|
||||
export default model<StatInterface>('Stat', Stat);
|
|
@ -1,22 +0,0 @@
|
|||
export { default as Customer, CustomerInterface } from './Customer';
|
||||
export { default as CustomerPortal, CustomerPortalInterface } from './CustomerPortal';
|
||||
export { default as File, FileInterface } from './File';
|
||||
export { default as ExecutiveOrder, ExecutiveOrderInterface } from './ExecutiveOrder';
|
||||
export { default as Inquiry, InquiryInterface, InqType } from './Inquiry';
|
||||
export { default as Judgement, JudgementInterface } from './Judgement';
|
||||
export { default as Member, MemberInterface } from './Member';
|
||||
export { default as Merchant, MerchantInterface } from './Merchant';
|
||||
export { default as Moderation, ModerationInterface } from './Moderation';
|
||||
export { default as Motion, MotionInterface } from './Motion';
|
||||
export { default as Note, NoteInterface } from './Note';
|
||||
export { default as PagerNumber, PagerNumberInterface, PagerNumberRaw } from './PagerNumber';
|
||||
export { default as Promo, PromoInterface } from './Promo';
|
||||
export { default as Proclamation, ProclamationInterface } from './Proclamation';
|
||||
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 SAA, SAAInterface } from './SAA';
|
||||
export { default as Score, ScoreInterface, ScoreInterfaceRaw } from './Score';
|
||||
export { default as ScoreHistorical, ScoreHistoricalInterface } from './ScoreHistorical';
|
||||
export { default as Staff, StaffInterface } from './Staff';
|
||||
export { default as Stat, StatInterface } from './Stat';
|
|
@ -16,9 +16,9 @@ export default class PageDTMF extends Handler {
|
|||
if (event.application !== 'page-dtmf') return;
|
||||
const message = await (<TextableChannel> this.client.guilds.get(this.client.config.guildID).channels.get('501089664040697858')).getMessage('775604192013320203');
|
||||
if (!message) return Misc.accessDenied(channel);
|
||||
const member = await this.client.db.Staff.findOne({ extension: channel.caller.number }).lean().exec();
|
||||
const member = await this.client.db.mongo.Staff.findOne({ extension: channel.caller.number }).lean().exec();
|
||||
if (!member) return Misc.accessDenied(channel);
|
||||
const pager = await this.client.db.PagerNumber.findOne({ individualAssignID: member.userID }).lean().exec();
|
||||
const pager = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: member.userID }).lean().exec();
|
||||
if (!pager) return Misc.accessDenied(channel);
|
||||
let status = 0;
|
||||
const pagerNumber: string[] = [];
|
||||
|
|
Loading…
Reference in New Issue