database logic rewrite

master
Matthew 2022-03-01 12:18:21 -05:00
parent 40aef4123b
commit b5613a43ff
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
98 changed files with 16601 additions and 19110 deletions

View File

@ -42,7 +42,8 @@
"no-multiple-empty-lines": "off", "no-multiple-empty-lines": "off",
"consistent-return": "off", "consistent-return": "off",
"no-continue": "off", "no-continue": "off",
"no-plusplus": "off" "no-plusplus": "off",
"no-undef": "off"
}, },
"ignorePatterns": "**/*.js" "ignorePatterns": "**/*.js"
} }

4023
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,7 @@
"brain.js": "^2.0.0-beta.4", "brain.js": "^2.0.0-beta.4",
"bull": "^4.1.1", "bull": "^4.1.1",
"cheerio": "^1.0.0-rc.10", "cheerio": "^1.0.0-rc.10",
"cr-db": "git+https://gitlab.libraryofcode.org/engineering/community-relations/database.git",
"cron": "^1.8.2", "cron": "^1.8.2",
"eris": "^0.16.1", "eris": "^0.16.1",
"eris-pagination": "github:libraryofcode/eris-pagination", "eris-pagination": "github:libraryofcode/eris-pagination",

View File

@ -1,8 +1,8 @@
import { Guild, GuildTextableChannel, Member, TextChannel } from 'eris'; import { Guild, GuildTextableChannel, Member, TextChannel } from 'eris';
import { v4 as genUUID } from 'uuid'; import { v4 as genUUID } from 'uuid';
import { Request } from 'express'; import { Request } from 'express';
import { Staff } from 'cr-db/mongodb';
import { RichEmbed, Route, Server } from '../../../class'; import { RichEmbed, Route, Server } from '../../../class';
import { StaffInterface } from '../../../models';
export default class Root extends Route { export default class Root extends Route {
constructor(server: Server) { constructor(server: Server) {
@ -33,7 +33,7 @@ export default class Root extends Route {
private async authenticate(req: Request) { private async authenticate(req: Request) {
if (!req.headers.authorization) return false; 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); const director = users.find((user) => user.pin.join('-') === req.headers.authorization);
if (!director) return false; if (!director) return false;
@ -41,7 +41,7 @@ export default class Root extends Route {
if (!member) return false; if (!member) return false;
if (!member.roles.includes(this.directorRole)) 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 }; return { member, director: staffProfile };
} }
@ -50,7 +50,7 @@ export default class Root extends Route {
id: string, id: string,
type: 'eo' | 'motion' | 'proc' | 'res' | 'confirmMotion', type: 'eo' | 'motion' | 'proc' | 'res' | 'confirmMotion',
director: { director: {
user: StaffInterface, user: Staff,
member: Member member: Member
}, },
payload: { 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 page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
const counts = { const counts = {
eo: await this.server.client.db.ExecutiveOrder.countDocuments(), eo: await this.server.client.db.mongo.ExecutiveOrder.countDocuments(),
motion: await this.server.client.db.Motion.countDocuments(), motion: await this.server.client.db.mongo.Motion.countDocuments(),
proc: await this.server.client.db.Proclamation.countDocuments(), proc: await this.server.client.db.mongo.Proclamation.countDocuments(),
resolution: await this.server.client.db.Resolution.countDocuments(), resolution: await this.server.client.db.mongo.Resolution.countDocuments(),
}; };
const eo = await this.server.client.db.ExecutiveOrder.find().skip(page * 4); const eo = await this.server.client.db.mongo.ExecutiveOrder.find().skip(page * 4);
const motion = await this.server.client.db.Motion.find().skip(page * 4); const motion = await this.server.client.db.mongo.Motion.find().skip(page * 4);
const proc = await this.server.client.db.Proclamation.find().skip(page * 4); const proc = await this.server.client.db.mongo.Proclamation.find().skip(page * 4);
const resolution = await this.server.client.db.Resolution.find().skip(page * 4); const resolution = await this.server.client.db.mongo.Resolution.find().skip(page * 4);
const returned: { const returned: {
id: string; id: string;
@ -291,7 +291,7 @@ export default class Root extends Route {
const msg = await this.brsVotingChannel.createMessage({ embed }); const msg = await this.brsVotingChannel.createMessage({ embed });
await this.brsLogChannel.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, issuer: authenticated.director.userID,
subject: req.body.subject, subject: req.body.subject,
body: req.body.body, body: req.body.body,
@ -338,7 +338,7 @@ export default class Root extends Route {
const msg = await this.brsVotingChannel.createMessage({ embed }); const msg = await this.brsVotingChannel.createMessage({ embed });
await this.brsLogChannel.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, issuer: authenticated.director.userID,
subject: req.body.subject, subject: req.body.subject,
body: req.body.body, body: req.body.body,
@ -388,7 +388,7 @@ export default class Root extends Route {
await msg.addReaction('modError:578750737920688128'); await msg.addReaction('modError:578750737920688128');
await msg.addReaction('🙋'); 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, issuer: authenticated.director.userID,
subject: req.body.subject, subject: req.body.subject,
body: req.body.body, 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) { if (!eo) {
return res.status(404).json({ 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, 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) { if (!motion) {
return res.status(404).json({ 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, 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) { if (!proc) {
return res.status(404).json({ 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, code: this.constants.codes.SUCCESS,
@ -511,7 +511,7 @@ export default class Root extends Route {
}); });
this.router.get('/eo/:id', async (req, res) => { 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) { if (!eo) {
return res.status(404).json({ return res.status(404).json({
@ -521,7 +521,7 @@ export default class Root extends Route {
} }
const issuer = this.guild.members.get(eo.issuer); 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, code: this.constants.codes.SUCCESS,
@ -540,7 +540,7 @@ export default class Root extends Route {
}); });
this.router.get('/motion/:id', async (req, res) => { 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) { if (!motion) {
return res.status(404).json({ return res.status(404).json({
@ -550,7 +550,7 @@ export default class Root extends Route {
} }
const issuer = this.guild.members.get(motion.issuer); 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, code: this.constants.codes.SUCCESS,
@ -571,7 +571,7 @@ export default class Root extends Route {
}); });
this.router.get('/proc/:id', async (req, res) => { 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) { if (!proc) {
return res.status(404).json({ return res.status(404).json({
@ -581,7 +581,7 @@ export default class Root extends Route {
} }
const issuer = this.guild.members.get(proc.issuer); 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, code: this.constants.codes.SUCCESS,
@ -602,7 +602,7 @@ export default class Root extends Route {
}); });
this.router.get('/resolution/:id', async (req, res) => { 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) { if (!resolution) {
return res.status(404).json({ return res.status(404).json({
@ -612,7 +612,7 @@ export default class Root extends Route {
} }
const issuer = this.guild.members.get(resolution.issuer); 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({ res.status(200).json({
code: this.constants.codes.SUCCESS, 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) { if (!eo) {
return res.status(404).json({ 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) { if (!motion) {
return res.status(404).json({ 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) { if (!proc) {
return res.status(404).json({ 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) { if (!resolution) {
return res.status(404).json({ 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 page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
const skipped = page || page * 10; 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: { const returned: {
oID: string; oID: string;
author: 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 page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
const skipped = page || page * 10; 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: { const returned: {
oID: string; oID: string;
author: 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 page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
const skipped = page || page * 10; 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: { const returned: {
oID: string; oID: string;
author: 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 page = !Number.isNaN(Number(req.query.page)) ? Number(req.query.page) : 0;
const skipped = page || page * 10; 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: { const returned: {
oID: string; oID: string;
author: 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) { if (!motion) {
return res.status(404).json({ return res.status(404).json({
@ -1032,7 +1032,7 @@ export default class Root extends Route {
const resolutionMessage = await this.brsVotingChannel.createMessage({ embed: resolutionEmbed }); const resolutionMessage = await this.brsVotingChannel.createMessage({ embed: resolutionEmbed });
const resolutionID = genUUID(); const resolutionID = genUUID();
await this.server.client.db.Resolution.create({ await this.server.client.db.mongo.Resolution.create({
issuer: motion.issuer, issuer: motion.issuer,
subject: motion.subject, subject: motion.subject,
body: motion.body, body: motion.body,

View File

@ -1,2 +1,3 @@
export { default as internal } from './internal';
export { default as keys } from './keys'; export { default as keys } from './keys';
export { default as report } from './report'; export { default as report } from './report';

View File

@ -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);
});
}
}

View File

@ -21,7 +21,7 @@ export default class Keys extends Route {
}); });
this.router.get('/p/:type/x509/:userID', async (req, res) => { 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); 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 (!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'); 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) => { 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); 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 (!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'); 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) => { 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); 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 (!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) => { 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); 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 (!member || !memberDoc || !memberDoc?.pgp) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });

View File

@ -2,8 +2,8 @@
/* eslint-disable no-continue */ /* eslint-disable no-continue */
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import { TextChannel } from 'eris'; import { TextChannel } from 'eris';
import { ScoreHistorical } from 'cr-db/mongodb';
import { LocalStorage, Route, Server } from '../../../class'; import { LocalStorage, Route, Server } from '../../../class';
import { ScoreHistoricalInterface, ScoreHistoricalRaw } from '../../../models/ScoreHistorical';
import { getTotalMessageCount } from '../../../intervals/score'; import { getTotalMessageCount } from '../../../intervals/score';
export default class Report extends Route { 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.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 }); 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 }); 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 }); 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)); 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 (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)) { 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); const chan = await this.server.client.getDMChannel(member.userID);
try { 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>.`); 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'); if ((mem.user.publicFlags & (1 << 17)) === 1 << 17) flags.push('EARLY_VERIFIED_BOT_DEVELOPER');
} }
const set = []; 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) { for (const sc of accounts) {
if (sc.total < 200) { continue; } if (sc.total < 200) { continue; }
if (sc.total > 800) { set.push(800); 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 if (member.cloudServices > 10) cloudServicesScore = 10;
else cloudServicesScore = Math.round(member.cloudServices); 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 }?] = []; const inquiries: [{ id?: string, name: string, date: Date }?] = [];
if (inqs?.length > 0) { if (inqs?.length > 0) {
for (const inq of inqs) { 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 historicalData = await this.server.client.db.mongo.ScoreHistorical.find({ userID: member.userID }).lean().exec();
const array: ScoreHistoricalRaw[] = []; const array: ScoreHistorical[] = [];
for (const data of historicalData) { for (const data of historicalData) {
let total: number; let total: number;
let activity: 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); 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({ return res.status(200).json({
code: this.constants.codes.SUCCESS, 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.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 }); 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 }); 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 }); if (!report) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
let totalScore: number; let totalScore: number;
@ -226,7 +226,7 @@ export default class Report extends Route {
else if (report.total > 800) totalScore = 800; else if (report.total > 800) totalScore = 800;
else totalScore = Math.round(report.total); 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)); 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); await this.server.client.report.createInquiry(report.userID, merchant.name.toUpperCase(), 1);
@ -257,7 +257,7 @@ export default class Report extends Route {
} }
const set = []; const set = [];
if (req.query.p?.toString() === 'true') { 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) { for (const sc of accounts) {
if (sc.total < 200) { continue; } if (sc.total < 200) { continue; }
if (sc.total > 800) { set.push(800); 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; let activityScore: number;
const moderationScore = Math.round(report.moderation); const moderationScore = Math.round(report.moderation);
@ -289,8 +289,8 @@ export default class Report extends Route {
else if (report.cloudServices > 10) cloudServicesScore = 10; else if (report.cloudServices > 10) cloudServicesScore = 10;
else cloudServicesScore = Math.round(report.cloudServices); else cloudServicesScore = Math.round(report.cloudServices);
const historicalData = await this.server.client.db.ScoreHistorical.find({ userID: report.userID }).lean().exec(); const historicalData = await this.server.client.db.mongo.ScoreHistorical.find({ userID: report.userID }).lean().exec();
const array: ScoreHistoricalRaw[] = []; const array: ScoreHistorical[] = [];
for (const data of historicalData) { for (const data of historicalData) {
let total: number; let total: number;
let activity: 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.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 }); 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 }); 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 }); 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)); 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 }); 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 if (member.total > 800) totalScore = 800;
else totalScore = Math.round(member.total); 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); await this.server.client.report.createInquiry(member.userID, merchant.name.toUpperCase(), 1);
if (!merchant.privileged) { if (!merchant.privileged) {
@ -433,7 +433,7 @@ export default class Report extends Route {
const args = req.query.pin.toString(); const args = req.query.pin.toString();
this.timeout.set(req.ip, 1); this.timeout.set(req.ip, 1);
setTimeout(() => this.timeout.delete(req.ip), 1800000); 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 }); 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); 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 }); 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) { if (req.query.staff) {
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
const args = req.query.staff.toString(); 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) 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 }); if (!staffScore.staff) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
this.timeout.delete(req.ip); this.timeout.delete(req.ip);
@ -454,7 +454,7 @@ export default class Report extends Route {
} else if (!updated) { } else if (!updated) {
await this.server.client.report.createInquiry(member.user.id, `${member.username} via report.libraryofcode.org @ IP ${req.ip}`, 1); 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 totalScore = '0';
let activityScore = '0'; let activityScore = '0';
@ -488,9 +488,9 @@ export default class Report extends Route {
else if (score.cloudServices > 10) cloudServicesScore = '10'; else if (score.cloudServices > 10) cloudServicesScore = '10';
else cloudServicesScore = `${score.cloudServices}`; 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) { for (const data of historical) {
let total: number; 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; 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 hardInquiries: [{ id?: string, name: string, reason: string, date: Date }?] = [];
const softInquiries: [{ id?: string, name: string, date: Date }?] = []; const softInquiries: [{ id?: string, name: string, date: Date }?] = [];
for (const inq of inqs) { for (const inq of inqs) {

View File

@ -12,7 +12,7 @@ export default class Root extends Route {
this.router.get('/m/:id', async (req, res) => { this.router.get('/m/:id', async (req, res) => {
try { try {
const id = req.params.id.split('.')[0]; 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) 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 (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') { if (req.query.d === '1') {

View File

@ -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()); 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) 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 }); 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; let status = false;
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) status = true; 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 }); 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); return res.status(200).json(acknowledgements);
} catch (err) { } catch (err) {
return this.handleError(err, res); 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?.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 }); if (!req.query.pin) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
const args = req.query.pin.toString(); 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 }); 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 }); return res.status(200).json({ userID: user.userID });
} catch (err) { } 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?.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 }); 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 }); 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 }); return res.status(200).json({ pin: report.pin });
} catch (err) { } catch (err) {
@ -89,7 +89,7 @@ export default class Internal extends Route {
return res.sendStatus(400); return res.sendStatus(400);
case 'customer.subscription.created': case 'customer.subscription.created':
if (data.items.data[0].price.product === 'prod_Hi4EYmf2am5VZt') { 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); if (!customer) return res.sendStatus(404);
await axios({ await axios({
method: 'get', method: 'get',
@ -100,7 +100,7 @@ export default class Internal extends Route {
break; break;
case 'customer.subscription.deleted': case 'customer.subscription.deleted':
if (data.items.data[0].price.product === 'prod_Hi4EYmf2am5VZt') { 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); if (!customer) return res.sendStatus(404);
await axios({ await axios({
method: 'get', method: 'get',

View File

@ -1,5 +1,4 @@
import { Route, Server } from '../../../class'; import { Route, Server } from '../../../class';
import { RedirectRaw } from '../../../models';
export default class Root extends Route { export default class Root extends Route {
constructor(server: Server) { constructor(server: Server) {
@ -14,11 +13,11 @@ export default class Root extends Route {
this.router.get('/dash', async (req, res) => { this.router.get('/dash', async (req, res) => {
try { 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 (!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 }); 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) { if (!customer) {
const newCus = await this.server.client.stripe.customers.create({ const newCus = await this.server.client.stripe.customers.create({
email: lookup.emailAddress, email: lookup.emailAddress,
@ -27,7 +26,7 @@ export default class Root extends Route {
username: lookup.username, username: lookup.username,
}, },
}); });
await (new this.server.client.db.Customer({ await (new this.server.client.db.mongo.Customer({
cusID: newCus.id, cusID: newCus.id,
userID: lookup.userID, userID: lookup.userID,
})).save(); })).save();
@ -51,10 +50,10 @@ export default class Root extends Route {
this.router.get('/:key', async (req, res) => { this.router.get('/:key', async (req, res) => {
try { 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 }); if (!link) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
res.redirect(link.to); 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) { } catch (err) {
this.server.client.util.handleError(err); this.server.client.util.handleError(err);
return res.status(500).json({ code: this.constants.codes.SERVER_ERROR, message: this.constants.messages.SERVER_ERROR }); return res.status(500).json({ code: this.constants.codes.SERVER_ERROR, message: this.constants.messages.SERVER_ERROR });

View File

@ -1,35 +1,14 @@
import Stripe from 'stripe'; import Stripe from 'stripe';
import Redis from 'ioredis';
import eris from 'eris'; import eris from 'eris';
import pluris from 'pluris'; import pluris from 'pluris';
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import Database from 'cr-db';
import { Collection, Command, InteractionCommand, LocalStorage, Queue, Util, ServerManagement, Event } from '.'; 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 import { Config } from '../../types'; // eslint-disable-line
// @ts-ignore
pluris(eris, { endpoints: false }); pluris(eris, { endpoints: false });
export default class Client extends eris.Client { export default class Client extends eris.Client {
@ -52,32 +31,11 @@ export default class Client extends eris.Client {
public stripe: Stripe; public stripe: Stripe;
public db: { public db: {
Customer: mongoose.Model<CustomerInterface>, mongo: typeof Database.MongoDBModels,
CustomerPortal: mongoose.Model<CustomerPortalInterface>, maria: null,
ExecutiveOrder: mongoose.Model<ExecutiveOrderInterface>, redis: Redis.Redis,
File: mongoose.Model<FileInterface>, local: { muted: LocalStorage },
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 }
}; };
constructor(token: string, options?: eris.ClientOptions) { constructor(token: string, options?: eris.ClientOptions) {
@ -89,29 +47,12 @@ export default class Client extends eris.Client {
this.intervals = new Collection<NodeJS.Timeout>(); this.intervals = new Collection<NodeJS.Timeout>();
this.queue = new Queue(this); this.queue = new Queue(this);
this.db = { this.db = {
Customer, mongo: Database.MongoDBModels,
CustomerPortal, redis: new Redis(),
ExecutiveOrder, local: {
File, muted: new LocalStorage('muted'),
Inquiry, },
Judgement, maria: null,
Member,
Merchant,
Moderation,
Motion,
Note,
PagerNumber,
Promo,
Proclamation,
Rank,
Redirect,
Resolution,
SAA,
Score,
ScoreHistorical,
Staff,
Stat,
local: { muted: new LocalStorage('muted') },
}; };
} }
@ -129,22 +70,22 @@ export default class Client extends eris.Client {
minPoolSize: 50, minPoolSize: 50,
}); });
const statMessages = await this.db.Stat.findOne({ name: 'messages' }); const statMessages = await this.db.mongo.Stat.findOne({ name: 'messages' });
const statCommands = await this.db.Stat.findOne({ name: 'commands' }); const statCommands = await this.db.mongo.Stat.findOne({ name: 'commands' });
const statPages = await this.db.Stat.findOne({ name: 'pages' }); const statPages = await this.db.mongo.Stat.findOne({ name: 'pages' });
const statRequests = await this.db.Stat.findOne({ name: 'requests' }); const statRequests = await this.db.mongo.Stat.findOne({ name: 'requests' });
if (!statMessages) { 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) { 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) { 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) { if (!statRequests) {
await (new this.db.Stat({ name: 'requests', value: 0 }).save()); await (new this.db.mongo.Stat({ name: 'requests', value: 0 }).save());
} }
} }

View File

@ -3,7 +3,6 @@ import { Member, User } from 'eris';
import { randomBytes } from 'crypto'; import { randomBytes } from 'crypto';
import moment, { unitOfTime } from 'moment'; import moment, { unitOfTime } from 'moment';
import { Client, RichEmbed } from '.'; import { Client, RichEmbed } from '.';
import { Moderation as ModerationModel, ModerationInterface } from '../models';
import { moderation as channels } from '../configs/channels.json'; import { moderation as channels } from '../configs/channels.json';
export default class Moderation { export default class Moderation {
@ -40,11 +39,11 @@ export default class Moderation {
return moment.duration(length, unit).asMilliseconds(); 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'); 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); await this.client.guilds.get(this.client.config.guildID).banMember(user.id, 7, reason);
const logID = randomBytes(2).toString('hex'); const logID = randomBytes(2).toString('hex');
const mod = new ModerationModel({ const mod = new this.client.db.mongo.Moderation({
userID: user.id, userID: user.id,
logID, logID,
moderatorID: moderator.id, moderatorID: moderator.id,
@ -81,12 +80,12 @@ export default class Moderation {
return mod.save(); 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); this.client.unbanGuildMember(this.client.config.guildID, userID, reason);
const user = await this.client.getRESTUser(userID); const user = await this.client.getRESTUser(userID);
if (!user) throw new Error('Cannot get user.'); if (!user) throw new Error('Cannot get user.');
const logID = randomBytes(2).toString('hex'); const logID = randomBytes(2).toString('hex');
const mod = new ModerationModel({ const mod = new this.client.db.mongo.Moderation({
userID, userID,
logID, logID,
moderatorID: moderator.id, moderatorID: moderator.id,
@ -111,13 +110,13 @@ export default class Moderation {
return mod.save(); 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'); 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); const member = await this.client.getRESTGuildMember(this.client.config.guildID, user.id);
if (!member) throw new Error('Cannot find member.'); if (!member) throw new Error('Cannot find member.');
await member.addRole('478373942638149643', `Muted by ${moderator.username}#${moderator.discriminator}`); await member.addRole('478373942638149643', `Muted by ${moderator.username}#${moderator.discriminator}`);
const logID = randomBytes(2).toString('hex'); const logID = randomBytes(2).toString('hex');
const mod = new ModerationModel({ const mod = new this.client.db.mongo.Moderation({
userID: user.id, userID: user.id,
logID, logID,
moderatorID: moderator.id, moderatorID: moderator.id,
@ -155,14 +154,14 @@ export default class Moderation {
return mod.save(); 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 member = await this.client.getRESTGuildMember(this.client.config.guildID, userID);
const user = await this.client.getRESTUser(userID); const user = await this.client.getRESTUser(userID);
if (member) { if (member) {
await member.removeRole('478373942638149643'); await member.removeRole('478373942638149643');
} }
const logID = randomBytes(2).toString('hex'); const logID = randomBytes(2).toString('hex');
const mod = new ModerationModel({ const mod = new this.client.db.mongo.Moderation({
userID, userID,
logID, logID,
moderatorID: moderator.id, moderatorID: moderator.id,
@ -189,11 +188,11 @@ export default class Moderation {
return mod.save(); 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'); 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); await this.client.guilds.get(this.client.config.guildID).kickMember(user.id, reason);
const logID = randomBytes(2).toString('hex'); const logID = randomBytes(2).toString('hex');
const mod = new ModerationModel({ const mod = new this.client.db.mongo.Moderation({
userID: user.id, userID: user.id,
logID, logID,
moderatorID: moderator.id, moderatorID: moderator.id,

View File

@ -1,10 +1,10 @@
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
/* eslint-disable no-eval */ /* eslint-disable no-eval */
import Bull from 'bull'; import Bull from 'bull';
import { InqType, Score } from 'cr-db/mongodb';
import cron from 'cron'; import cron from 'cron';
import { TextableChannel, TextChannel } from 'eris'; import { TextableChannel, TextChannel } from 'eris';
import { Client, RichEmbed } from '.'; import { Client, RichEmbed } from '.';
import { ScoreInterface, InqType as InquiryType } from '../models';
import { apply as Apply } from '../commands'; import { apply as Apply } from '../commands';
@ -25,12 +25,12 @@ export default class Queue {
protected setCronJobs() { protected setCronJobs() {
const historialCommunityReportJob = new cron.CronJob('0 20 * * *', async () => { const historialCommunityReportJob = new cron.CronJob('0 20 * * *', async () => {
try { 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(); const startDate = new Date();
for (const report of reports) { for (const report of reports) {
const inqs = await this.client.db.Inquiry.find({ userID: report.userID }); const inqs = await this.client.db.mongo.Inquiry.find({ userID: report.userID });
const data = new this.client.db.ScoreHistorical({ const data = new this.client.db.mongo.ScoreHistorical({
userID: report.userID, userID: report.userID,
report: { report: {
total: report.total, total: report.total,
@ -52,7 +52,7 @@ export default class Queue {
}); });
const clearOldHistoricalReportsJob = new cron.CronJob('0 22 * * *', async () => { 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(); historialCommunityReportJob.start();
@ -92,11 +92,11 @@ export default class Queue {
} }
protected setProcessors() { 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 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(); const embed = new RichEmbed();
if (job.data.type === InquiryType.HARD) { if (job.data.type === InqType.Hard) {
embed.setTitle('Inquiry Notification'); embed.setTitle('Inquiry Notification');
embed.setDescription(job.data.inqID); embed.setDescription(job.data.inqID);
embed.setColor('#800080'); 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'); const log = <TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('611584771356622849');
log.createMessage({ embed }).catch(() => {}); 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 }>) => { 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.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() } }); 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) { 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 }>) => { 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 }); return this.queues.score.add('score::inquiry', { inqID, userID, name, type, reason });
} }
/** /**
* @deprecated * @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 }); return this.queues.score.add('score::update', { score, total, activity, roles, moderation, cloudServices, other, staff });
} }

View File

@ -1,6 +1,6 @@
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { InqType } from 'cr-db/mongodb';
import { Client } from '.'; import { Client } from '.';
import { InqType } from '../models';
export default class Report { export default class Report {
public client: Client; public client: Client;
@ -10,11 +10,11 @@ export default class Report {
} }
public async createInquiry(userID: string, name: string, type: InqType, reason?: string) { 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)); const member = this.client.util.resolveMember(userID, this.client.guilds.get(this.client.config.guildID));
if (!report || !member) return null; if (!report || !member) return null;
if (type === InqType.HARD && report.locked) return null; if (type === InqType.Hard && report.locked) return null;
const mod = await (new this.client.db.Inquiry({ const mod = await (new this.client.db.mongo.Inquiry({
iid: uuid(), iid: uuid(),
userID, userID,
name, name,
@ -30,7 +30,7 @@ export default class Report {
} }
/* public async soft(userID: string) { /* 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; if (!report) return null;
let totalScore: number; let totalScore: number;
let activityScore: number; let activityScore: number;
@ -59,7 +59,7 @@ export default class Report {
else if (report.cloudServices > 10) cloudServicesScore = 10; else if (report.cloudServices > 10) cloudServicesScore = 10;
else cloudServicesScore = Math.round(report.cloudServices); 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[] = []; const array: ScoreHistoricalRaw[] = [];
for (const data of historicalData) { for (const data of historicalData) {
let total: number; let total: number;

View File

@ -20,7 +20,7 @@ export default class Route {
public init() { public init() {
this.router.all('*', (req, res, next) => { 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.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 }); 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 if (this.conf.deprecated === true) res.status(501).json({ code: this.constants.codes.DEPRECATED, message: this.constants.messages.DEPRECATED });
else next(); else next();

View File

@ -23,9 +23,9 @@ export default class AddItem extends Command {
return message.channel.createMessage({ embed }); 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])) { 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) { if (!account) {
const newAccount = new this.client.db.Member({ const newAccount = new this.client.db.mongo.Member({
userID: message.member.id, userID: message.member.id,
additional: { additional: {
operatingSystems: [args[0].split('-')[1]], 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.***`); 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])) { 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) { if (!account) {
const newAccount = new this.client.db.Member({ const newAccount = new this.client.db.mongo.Member({
userID: message.member.id, userID: message.member.id,
additional: { additional: {
langs: [args[0].split('-')[1]], langs: [args[0].split('-')[1]],

View File

@ -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[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.'); if ((Number(args[1]) !== 0) && (Number(args[1]) !== 1)) return this.error(message.channel, 'Invalid permissions.');
const key = randomBytes(20).toString('hex'); 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(' '), name: args.slice(2).join(' '),
privileged: Number(args[0]), privileged: Number(args[0]),
type: Number(args[1]), type: Number(args[1]),

View File

@ -31,7 +31,7 @@ export default class AddNote extends Command {
note.category = args[args.length - 1]; note.category = args[args.length - 1];
note.text = args.slice(0, args.length - 1).join(' '); 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}\`.`); return this.success(message.channel, `Successfully created Note # \`${saved._id}\`.`);
} catch (err) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);

View File

@ -18,7 +18,7 @@ export default class AddPromoCode extends Command {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
try { try {
const pcd = await this.client.stripe.promotionCodes.retrieve(args[0]); 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, code: pcd.code,
pID: args[0], pID: args[0],
}); });

View File

@ -20,7 +20,7 @@ export default class AddRank extends Command {
const role = this.client.util.resolveRole(args[0], this.mainGuild); 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.'); 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.'); if (check) return this.error(message.channel, 'This role is already self-assignable.');
let permissions: string[]; let permissions: string[];
@ -30,7 +30,7 @@ export default class AddRank extends Command {
permissions = args[1].split(':'); permissions = args[1].split(':');
} }
const entry = new this.client.db.Rank({ const entry = new this.client.db.mongo.Rank({
name: role.name, name: role.name,
roleID: role.id, roleID: role.id,
permissions, permissions,

View File

@ -15,7 +15,7 @@ export default class AddRedirect extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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}`); if (check) return this.error(message.channel, `Redirect key ${args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
try { try {
const test = new URL(args[0]); 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.'); 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.'); 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(), key: args[1].toLowerCase(),
to: args[0], to: args[0],
visitedCount: 0, visitedCount: 0,

View File

@ -2,6 +2,7 @@
import type { AxiosError, AxiosStatic } from 'axios'; import type { AxiosError, AxiosStatic } from 'axios';
import axios from 'axios'; import axios from 'axios';
import { Member, Message } from 'eris'; import { Member, Message } from 'eris';
import { nanoid } from 'nanoid';
import { Client, Command, RichEmbed } from '../class'; import { Client, Command, RichEmbed } from '../class';
import { CloudServicesUtil } from '../util'; 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', { this.services.set('cs::temp-upgrade', {
description: 'Temporary Tier 3 upgrade for your Cloud Services account to install dependencies or RAM-dependent operations.', description: 'Temporary Tier 3 upgrade for your Cloud Services account to install dependencies or RAM-dependent operations.',
type: 'SOFT', type: 'SOFT',
url: 'https://eds.libraryofcode.org/cs/t3-temp', url: 'https://eds.libraryofcode.org/cs/t3-temp',
validation: async (member: Member) => { validation: async (member: Member) => {
const csAccount = await CloudServicesUtil.fetchAccountStatus(member.id, this.client.config.internalKey); 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 (new Date() > memberCheck?.misc?.t3TemporaryExpiration?.date) return false;
if (csAccount.tier === 3) return false; if (csAccount.tier === 3) return false;
return true; return true;
}, },
func: async (client: Client, ...data: any[]) => { func: async (client: Client, ...data: any[]) => {
const dmember = await client.guilds.get(client.config.guildID).getRESTMember(data[0]); 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 CloudServicesUtilP = <typeof CloudServicesUtil>require('../util/CloudServices').default;
const csAccount = await CloudServicesUtilP.fetchAccountStatus(dmember.id, this.client.config.internalKey); const csAccount = await CloudServicesUtilP.fetchAccountStatus(dmember.id, this.client.config.internalKey);
if (!member) { if (!member) {
const addMember = new this.client.db.Member({ const addMember = new this.client.db.mongo.Member({
userID: dmember.id, userID: dmember.id,
}); });
await addMember.save(); 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); 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', url: 'https://eds.libraryofcode.org/cs/t3-promo',
validation: async (member: Member) => { validation: async (member: Member) => {
if (!member.roles.includes('546457886440685578')) return false; 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; if (!customer) return false;
return true; return true;
}, },
func: async (client: Client, ...data: any[]) => { func: async (client: Client, ...data: any[]) => {
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]); 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({ const coupon = await client.stripe.coupons.create({
percent_off: 25, percent_off: 25,
duration: 'once', duration: 'once',
@ -132,7 +150,7 @@ export default class Apply extends Command {
first_time_transaction: true, first_time_transaction: true,
}, },
}); });
const doc = new client.db.Promo({ const doc = new client.db.mongo.Promo({
code: promo.code, code: promo.code,
pID: promo.id, pID: promo.id,
}); });

View File

@ -30,11 +30,11 @@ export default class Billing extends Command {
const portalKey = randomBytes(50).toString('hex'); const portalKey = randomBytes(50).toString('hex');
const uid = uuid(); const uid = uuid();
const redirect = new this.client.db.Redirect({ const redirect = new this.client.db.mongo.Redirect({
key: uid, key: uid,
to: `https://loc.sh/dash?q=${portalKey}`, to: `https://loc.sh/dash?q=${portalKey}`,
}); });
const portal = new this.client.db.CustomerPortal({ const portal = new this.client.db.mongo.CustomerPortal({
key: portalKey, key: portalKey,
username: message.author.username, username: message.author.username,
userID: message.author.id, userID: message.author.id,

View File

@ -1,8 +1,8 @@
import axios from 'axios'; import axios from 'axios';
import Database from 'cr-db';
import { Message } from 'eris'; import { Message } from 'eris';
import type { Stripe } from 'stripe'; import type { Stripe } from 'stripe';
import { Client, Command } from '../class'; import { Client, Command } from '../class';
import type { PromoInterface } from '../models';
export default class Billing_T3 extends Command { export default class Billing_T3 extends Command {
constructor(client: Client) { 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; }>(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.'); 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.`); 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]) { 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>; let subscription: Stripe.Response<Stripe.Subscription>;

View File

@ -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('Member', `${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`, true);
embed.addField('Phone Number', phone.getNumber('national'), true); embed.addField('Phone Number', phone.getNumber('national'), true);
embed.addField('Phone Number Type', phone.getType(), 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) { if (communityReport) {
await this.client.report.createInquiry(member.user.id, 'Library of Code sp-us | VOIP/PBX Member Support SVCS', 1); 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); embed.addField('PIN', `${communityReport.pin[0]}-${communityReport.pin[1]}-${communityReport.pin[2]}`, true);

View File

@ -23,7 +23,7 @@ export default class DelItem extends Command {
return message.channel.createMessage({ embed }); 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])) { 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) { if (account?.additional.operatingSystems.length < 1) {
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any operating systems to remove.***`); 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.***`); 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])) { 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) { if (account?.additional.langs.length < 1) {
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any languages to remove.***`); return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any languages to remove.***`);
} }

View File

@ -16,7 +16,7 @@ export default class DelMerchant extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); if (!merchant) return this.error(message.channel, 'Merchant specified does not exist.');
return this.success(message.channel, `Deleted merchant \`${merchant._id}\`.`); return this.success(message.channel, `Deleted merchant \`${merchant._id}\`.`);
} catch (err) { } catch (err) {

View File

@ -15,9 +15,9 @@ export default class DelNote extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); 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.`); return this.success(message.channel, `Note # \`${note._id}\` has been deleted.`);
} catch (err) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);

View File

@ -18,7 +18,7 @@ export default class DeletePromoCode extends Command {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
try { try {
await this.client.stripe.promotionCodes.retrieve(args[0]); 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) { } catch (err) {
return this.error(message.channel, 'Promotional API ID doesn\'t exist.'); return this.error(message.channel, 'Promotional API ID doesn\'t exist.');
} }

View File

@ -18,10 +18,10 @@ export default class DelRank extends Command {
const role = this.client.util.resolveRole(args[0], this.mainGuild); 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.'); 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.'); 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.`); return this.success(message.channel, `Role ${role.name} is no longer self-assignable.`);
} catch (err) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);

View File

@ -15,9 +15,9 @@ export default class DelRedirect extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.`); 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()}.`); return this.success(message.channel, `Deleted redirect https://loc.sh/${args[0].toLowerCase()}.`);
} catch (err) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);

View File

@ -23,9 +23,9 @@ export default class Inquiry extends Command {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); 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.'); 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); const member = this.client.util.resolveMember(inquiry.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Could not locate member.'); if (!member) return this.error(message.channel, 'Could not locate member.');

View File

@ -20,16 +20,16 @@ export default class Inquiry_Remove extends Command {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); if (!inquiry) return this.error(message.channel, 'Unable to find Inquiry.');
const member = await this.client.util.resolveMember(inquiry.userID, this.mainGuild); const member = await this.client.util.resolveMember(inquiry.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.'); 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 (!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.'); 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(); const embed = new RichEmbed();
embed.setTitle('Inquiry - Removed'); embed.setTitle('Inquiry - Removed');

View File

@ -21,7 +21,7 @@ export default class Judgement_Add extends Command {
const member = this.client.util.resolveMember(args[0], this.mainGuild); const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.'); 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 (!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.'); 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 jid = nanoid(11);
const entry = new this.client.db.Judgement({ const entry = new this.client.db.mongo.Judgement({
jid, jid,
userID: member.user.id, userID: member.user.id,
enteredBy: message.author.id, enteredBy: message.author.id,

View File

@ -19,9 +19,9 @@ export default class Judgement_Delete extends Command {
const member = this.client.util.resolveMember(args[0], this.mainGuild); const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.'); 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 (!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.'); if (!judgement) return this.error(message.channel, 'Unable to locate judgement.');
await judgement.delete(); await judgement.delete();

View File

@ -16,7 +16,7 @@ export default class DelRedirect extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (args[0]) { 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.'); if (redirects.length <= 0) return this.error(message.channel, 'Could not find an entry matching that query.');
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Redirect Information'); embed.setTitle('Redirect Information');
@ -27,7 +27,7 @@ export default class DelRedirect extends Command {
embed.setTimestamp(); embed.setTimestamp();
return message.channel.createMessage({ embed }); 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.'); if (!redirects) return this.error(message.channel, 'No redirect links found.');
const redirectArray: [{ name: string, value: string }?] = []; const redirectArray: [{ name: string, value: string }?] = [];
for (const redirect of redirects) { for (const redirect of redirects) {

View File

@ -20,7 +20,7 @@ export default class Mute extends Command {
if (!member) return this.error(message.channel, 'Cannot find user.'); if (!member) return this.error(message.channel, 'Cannot find user.');
try { 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.'); 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 } catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.'); if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');

View File

@ -26,7 +26,7 @@ export default class Notes extends Command {
} }
if (!member) return this.error(message.channel, 'User specified could not be found.'); 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.'); if (!notes || notes?.length < 1) return this.error(message.channel, 'No notes exist for this user.');
const noteArray: [{ name: string, value: string, inline: boolean }?] = []; const noteArray: [{ name: string, value: string, inline: boolean }?] = [];

View File

@ -20,7 +20,7 @@ export default class Offer extends Command {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild); const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Could not find member.'); 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) 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.'); if (score.locked) return this.error(message.channel, 'This user\'s score report is locked.');

View File

@ -54,7 +54,7 @@ export default class Page extends Command {
return message.channel.createMessage({ embed }); return message.channel.createMessage({ embed });
} }
if (args[0] === 'settings') { 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.'); if (!pager) return this.error(message.channel, 'You do not have a Pager Number.');
switch (args[1]) { switch (args[1]) {
case 'email': case 'email':
@ -88,7 +88,7 @@ export default class Page extends Command {
} }
message.delete(); message.delete();
const loading = await this.loading(message.channel, 'Paging...'); 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.'); 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); const page = await this.page(args[0], sender.num, args[1], message, args[2] ? args.slice(2).join(' ') : undefined);
if (page.status === true) { 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}> { public async page(recipientNumber: string, senderNumber: string, code: string, message: Message, txt?: string, options?: { emergencyNumber: string }): Promise<{status: boolean, message: string}> {
try { try {
if (txt?.length >= 140) return { status: false, message: 'Your message must be less than 141 characters.' }; 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) { if (!senderEntry) {
return { status: false, message: 'You do not have a Pager Number.' }; 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' }); await this.page('20', senderNumber, code, message, txt, { emergencyNumber: '1' });
break; break;
case '#2': case '#2':
const matthew = await this.client.db.PagerNumber.findOne({ individualAssignID: '278620217221971968' }); const matthew = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: '278620217221971968' });
const bsian = await this.client.db.PagerNumber.findOne({ individualAssignID: '253600545972027394' }); const bsian = await this.client.db.mongo.PagerNumber.findOne({ individualAssignID: '253600545972027394' });
const nightraven = await this.client.db.PagerNumber.findOne({ individualAssignID: '239261547959025665' }); 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(matthew?.num, senderNumber, code, message, txt, { emergencyNumber: '2' });
await this.page(bsian?.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' }); 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.` }; 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) { if (!recipientEntry) {
return { status: false, message: `Pager Number \`${recipientNumber}\` does not exist.` }; 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) { /* 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; 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; if (!member || !member.extension) continue;
const fileExtension = `${randomBytes(10).toString('hex')}`; 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.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.` }; return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
} catch (err) { } catch (err) {
this.client.util.signale.error(err); this.client.util.signale.error(err);

View File

@ -39,7 +39,7 @@ export default class PGP extends Command {
} }
public async run(message: Message, args: string[]) { 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.'); if (!profile) return this.error(message.channel, 'Unable to find specified member\'s account.');
const embed = new RichEmbed() const embed = new RichEmbed()
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL()) .setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL())

View File

@ -14,7 +14,7 @@ export default class PGP_Remove extends Command {
} }
public async run(message: Message) { 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.'); if (!profile?.pgp) return this.error(message.channel, 'There are no PGP public keys connected to your account.');
await profile.updateOne({ $unset: { pgp: '' } }); await profile.updateOne({ $unset: { pgp: '' } });
this.success(message.channel, 'Unlinked PGP public key from your account.'); this.success(message.channel, 'Unlinked PGP public key from your account.');

View File

@ -16,8 +16,8 @@ export default class PGP_Upload extends Command {
public async run(message: Message) { public async run(message: Message) {
if (!message.attachments.length) return this.error(message.channel, 'Please upload your PGP public key as an attachment.'); 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 })) { if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.Member.create({ userID: message.author.id }); await this.client.db.mongo.Member.create({ userID: message.author.id });
} }
const [pgpAttachment] = message.attachments; const [pgpAttachment] = message.attachments;
const pgpReq: AxiosResponse<string> = await axios(pgpAttachment.url); const pgpReq: AxiosResponse<string> = await axios(pgpAttachment.url);
@ -27,7 +27,7 @@ export default class PGP_Upload extends Command {
} catch { } catch {
return this.error(message.channel, 'Unable to parse your PGP public key.'); 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.'); this.success(message.channel, 'PGP public key successfully uploaded to your account.');
} }
} }

View File

@ -17,8 +17,8 @@ export default class Profile extends Command {
} }
public async run(message: Message) { public async run(message: Message) {
if (!await this.client.db.Member.exists({ userID: message.author.id })) { if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.Member.create({ 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\`.`); 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\`.`);

View File

@ -12,10 +12,10 @@ export default class Profile_Bio extends Command {
} }
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
if (!await this.client.db.Member.exists({ userID: message.author.id })) { if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.Member.create({ 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]) { if (!args[0]) {
await member.updateOne({ await member.updateOne({

View File

@ -12,10 +12,10 @@ export default class Profile_GitHub extends Command {
} }
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
if (!await this.client.db.Member.exists({ userID: message.author.id })) { if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.Member.create({ 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]) { if (!args[0]) {
await member.updateOne({ await member.updateOne({
additional: { additional: {

View File

@ -12,11 +12,11 @@ export default class Profile_GitLab extends Command {
} }
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
if (!await this.client.db.Member.exists({ userID: message.author.id })) { if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.Member.create({ 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.'); 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]) { if (!args[0]) {
await member.updateOne({ await member.updateOne({
additional: { additional: {

View File

@ -16,7 +16,7 @@ export default class Rank extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) { 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 }?] = []; const rankArray: [{ name: string, value: string }?] = [];
for (const rank of roles.sort((a, b) => a.name.localeCompare(b.name))) { for (const rank of roles.sort((a, b) => a.name.localeCompare(b.name))) {
let perms: string; 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)); 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.'); 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 (!entry) return this.error(message.channel, 'The rank you specified doesn\'t exist.');
if (!message.member.roles.includes(entry.roleID)) { if (!message.member.roles.includes(entry.roleID)) {
let permCheck: boolean; let permCheck: boolean;

View File

@ -27,9 +27,9 @@ export default class StaffAssistedApplication extends Command {
const member = this.client.util.resolveMember(args[0], this.mainGuild); const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.'); 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.'); 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.'); if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
const service = this.applyCommand.services.get(args[1]); 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); 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, userID: member.id,
applicationID: application.id, applicationID: application.id,
serviceCode: args[1], serviceCode: args[1],

View File

@ -22,13 +22,13 @@ export default class SAA_Approve extends Command {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); if (!saa) return this.error(message.channel, 'Unable to locate SAA.');
const member = this.client.util.resolveMember(saa.userID, this.mainGuild); const member = this.client.util.resolveMember(saa.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.'); 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.'); 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.'); if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
await this.applyCommand.services.get(saa.serviceCode).func(this.client, member.id); 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); 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.')); chan.createMessage({ embed }).then(() => this.success(message.channel, 'SAA successfully processed.')).catch(() => this.error(message.channel, 'Unable to deliver decision to user.'));
await axios({ try {
method: 'PATCH', await axios({
url: `https://eds.libraryofcode.org/dec/${saa.applicationID}?auth=${this.client.config.internalKey}`, method: 'PATCH',
data: { status: true }, 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) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);
} }

View File

@ -21,13 +21,13 @@ export default class SAA_Decline extends Command {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); if (!saa) return this.error(message.channel, 'Unable to locate SAA.');
const member = this.client.util.resolveMember(saa.userID, this.mainGuild); const member = this.client.util.resolveMember(saa.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.'); 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.'); 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.'); if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
const embed = new RichEmbed(); const embed = new RichEmbed();
@ -49,7 +49,7 @@ export default class SAA_Decline extends Command {
const chan = await this.client.getDMChannel(saa.userID); 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.')); 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) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);
} }

View File

@ -34,7 +34,7 @@ export default class Score extends Command {
} else { } else {
user = this.client.util.resolveMember(args[0], this.mainGuild)?.user; user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
if (!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.'); if (!sc) return this.error(message.channel, 'Member not found.');
user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user; 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]); if (args.length < 3) return this.client.commands.get('help').run(message, [this.name]);
const name = args.slice(2).join(' ').split(':')[0]; const name = args.slice(2).join(' ').split(':')[0];
const reason = args.slice(2).join(' ').split(':')[1]; 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) 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.'); 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); await this.client.report.createInquiry(score.userID, name, 0, reason);
} }
} }
if (!user) return this.error(message.channel, 'Member not found.'); if (!user) return this.error(message.channel, 'Member not found.');
const score = await this.client.db.Score.findOne({ userID: user.id }); const score = await this.client.db.mongo.Score.findOne({ userID: user.id });
const inqs = await this.client.db.Inquiry.find({ userID: user.id, type: 0 }); 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.'); if (!score) return this.error(message.channel, 'Community Report has not been generated yet.');
let totalScore = '0'; let totalScore = '0';
let activityScore = '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.'); } // else return this.error(message.channel, 'Community Score has not been calculated yet.');
const set = []; 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) { for (const sc of accounts) {
if (sc.total < 200) { continue; } if (sc.total < 200) { continue; }
if (sc.total > 800) { set.push(800); 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('Other', otherScore || 'N/C', true);
embed.addField('Misc', miscScore || 'N/C', true); embed.addField('Misc', miscScore || 'N/C', true);
let judgementsStr: string = ''; 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) { if (judgements?.length > 0) {
for (const judgement of judgements) { for (const judgement of judgements) {
let severity: string; let severity: string;

View File

@ -29,7 +29,7 @@ export default class Score_Hist extends Command {
} else { } else {
user = this.client.util.resolveMember(args[0], this.mainGuild)?.user; user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
if (!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; user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user;
let name = ''; let name = '';
@ -41,7 +41,7 @@ export default class Score_Hist extends Command {
} }
} }
if (!user) return this.error(message.channel, 'Member not found.'); 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) return this.error(message.channel, 'No history found.');
if (hists.length < 1) return this.error(message.channel, 'No history found.'); if (hists.length < 1) return this.error(message.channel, 'No history found.');
const totalArray: number[] = []; const totalArray: number[] = [];

View File

@ -16,15 +16,15 @@ export default class Score_Notify extends Command {
try { try {
const user = message.author; const user = message.author;
if (!user) return this.error(message.channel, 'Member not found.'); 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) 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]) { switch (args[0]) {
case 'on': 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.'); return this.success(message.channel, 'You will now be sent notifications whenever your score is hard-pulled.');
case 'off': 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.'); return this.success(message.channel, 'You will no longer be sent notifications when your score is hard-pulled.');
default: default:
return this.error(message.channel, 'Invalid option. Valid options are `on` and `off`.'); return this.error(message.channel, 'Invalid option. Valid options are `on` and `off`.');

View File

@ -15,15 +15,15 @@ export default class Score_Pref extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!message.author) return this.error(message.channel, 'Member not found.'); 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) 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]) { switch (args[0]) {
case 'lock': 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.'); return this.success(message.channel, 'Your report is now locked.');
case 'unlock': 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.'); return this.success(message.channel, 'Your report is now unlocked.');
default: default:
return this.error(message.channel, 'Invalid input'); return this.error(message.channel, 'Invalid input');

View File

@ -17,7 +17,7 @@ export default class SIP extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { 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.'); if (!staff || !staff?.extension) return this.error(message.channel, 'You must have an extension to complete this action.');
this.success(message.channel, 'Queued call.'); this.success(message.channel, 'Queued call.');

View File

@ -17,7 +17,7 @@ export default class SSS_Create_Account extends Command {
public async run(message: Message) { public async run(message: Message) {
try { 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.'); if (!staff) return this.error(message.channel, 'Staff information not located.');

View File

@ -17,7 +17,7 @@ export default class SSS_Password_Reset extends Command {
public async run(message: Message) { public async run(message: Message) {
try { 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.'); if (!staff) return this.error(message.channel, 'Staff information not located.');
const passwordTicket = await this.client.util.authClient.createPasswordChangeTicket({ const passwordTicket = await this.client.util.authClient.createPasswordChangeTicket({

View File

@ -14,10 +14,10 @@ export default class Stats extends Command {
public async run(message: Message) { public async run(message: Message) {
try { try {
const messages = await this.client.db.Stat.findOne({ name: 'messages' }); const messages = await this.client.db.mongo.Stat.findOne({ name: 'messages' });
const commands = await this.client.db.Stat.findOne({ name: 'commands' }); const commands = await this.client.db.mongo.Stat.findOne({ name: 'commands' });
const pages = await this.client.db.Stat.findOne({ name: 'pages' }); const pages = await this.client.db.mongo.Stat.findOne({ name: 'pages' });
const requests = await this.client.db.Stat.findOne({ name: 'requests' }); const requests = await this.client.db.mongo.Stat.findOne({ name: 'requests' });
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Statistics'); embed.setTitle('Statistics');

View File

@ -33,7 +33,7 @@ export default class StoreMessages extends Command {
const identifier = randomBytes(20).toString('hex'); const identifier = randomBytes(20).toString('hex');
const comp = await LocalStorage.compress(html); 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`, name: `${chan.name}-${new Date().toLocaleString('en-us')}.html.gz`,
identifier, identifier,
mimeType: 'application/gzip', mimeType: 'application/gzip',

View File

@ -19,7 +19,7 @@ export default class Unmute extends Command {
if (!member) return this.error(message.channel, 'Cannot find user.'); if (!member) return this.error(message.channel, 'Cannot find user.');
try { 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.'); 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 } catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.'); if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');

View File

@ -3,7 +3,6 @@ import moment from 'moment';
import { Message, Member } from 'eris'; import { Message, Member } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, Command, RichEmbed } from '../class';
import { whois as emotes } from '../configs/emotes.json'; import { whois as emotes } from '../configs/emotes.json';
import { profile } from '.';
export default class Whois extends Command { export default class Whois extends Command {
constructor(client: Client) { constructor(client: Client) {
@ -43,7 +42,7 @@ export default class Whois extends Command {
} }
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setThumbnail(member.avatarURL); 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); const mpn = this.memberPostNominals(member);
let title = `${member.user.username}#${member.user.discriminator}`; let title = `${member.user.username}#${member.user.discriminator}`;
if (!ackResolve && mpn) { if (!ackResolve && mpn) {
@ -63,14 +62,14 @@ export default class Whois extends Command {
if (ackResolve?.emailAddress) { if (ackResolve?.emailAddress) {
description += `${emotes.email} ${ackResolve.emailAddress}\n`; 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) { if (pager?.num) {
description += `📟 ${pager.num}\n`; description += `📟 ${pager.num}\n`;
} }
if (ackResolve?.extension) { if (ackResolve?.extension) {
description += `☎️ ${ackResolve.extension}\n`; 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) { if (memberProfile?.additional?.gitlab) {
description += `${emotes.gitlab} ${memberProfile?.additional.gitlab}\n`; 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('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('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); 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) { if (score) {
await this.client.report.createInquiry(member.id, 'Library of Code sp-us | Bureau of Community Reports', 1); await this.client.report.createInquiry(member.id, 'Library of Code sp-us | Bureau of Community Reports', 1);
let totalScore = '0'; let totalScore = '0';
@ -138,7 +137,7 @@ export default class Whois extends Command {
if (bit & 2) permissions.push('Kick Members'); 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) { if (account?.additional?.langs?.length > 0) {
const langs: string[] = []; const langs: string[] = [];
for (const lang of account.additional.langs.sort((a, b) => a.localeCompare(b))) { for (const lang of account.additional.langs.sort((a, b) => a.localeCompare(b))) {

View File

@ -58,7 +58,7 @@ export default class X509 extends Command {
} }
public async run(message: Message, args: string[]) { 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.'); if (!profile) return this.error(message.channel, 'Unable to find specified member\'s account.');
const embed = new RichEmbed() const embed = new RichEmbed()
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL()) .setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL())

View File

@ -14,7 +14,7 @@ export default class X509_Remove extends Command {
} }
public async run(message: Message) { 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.'); if (!profile?.x509) return this.error(message.channel, 'There are no X.509 certificates connected to your account.');
await profile.updateOne({ $unset: { x509: '' } }); await profile.updateOne({ $unset: { x509: '' } });
this.success(message.channel, 'Unlinked X.509 certificate from your account.'); this.success(message.channel, 'Unlinked X.509 certificate from your account.');

View File

@ -16,8 +16,8 @@ export default class X509_Upload extends Command {
public async run(message: Message) { public async run(message: Message) {
if (!message.attachments.length) return this.error(message.channel, 'Please upload your x509 certificate as an attachment.'); 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 })) { if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.Member.create({ userID: message.author.id }); await this.client.db.mongo.Member.create({ userID: message.author.id });
} }
const [x509Attachment] = message.attachments; const [x509Attachment] = message.attachments;
const x509Req: AxiosResponse<string> = await axios(x509Attachment.url); const x509Req: AxiosResponse<string> = await axios(x509Attachment.url);
@ -27,7 +27,7 @@ export default class X509_Upload extends Command {
} catch { } catch {
return this.error(message.channel, 'Unable to parse your x509 certificate.'); 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.'); this.success(message.channel, 'x509 certificate successfully uploaded to your account.');
} }
} }

View File

@ -12,7 +12,7 @@ export default class CommandHandler extends Event {
public async run(message: Message) { public async run(message: Message) {
try { 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.author.bot) return;
if (message.content.indexOf(this.client.config.prefix) !== 0) 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); 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}'.`); 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); 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) { } catch (err) {
this.client.util.handleError(err, message); this.client.util.handleError(err, message);
} }

View File

@ -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; 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}'.`); // 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); 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) { } catch (err) {
this.client.util.handleError(err); this.client.util.handleError(err);
} }

View File

@ -11,7 +11,7 @@ export default class GuildMemberAdd extends Event {
public async run(_, member: Member) { public async run(_, member: Member) {
try { 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) { if (search === true) {
member.addRole('478373942638149643', 'muted user left server and joined back'); member.addRole('478373942638149643', 'muted user left server and joined back');
} }

View File

@ -31,7 +31,7 @@ export default class MessageReactionAdd extends Event {
if (!reactor.roles.includes(this.directorRole)) return; 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)) { if (!proc?.votedDirectors.includes(reactor.id)) {
let type: 'yea' | 'nay' | 'present'; let type: 'yea' | 'nay' | 'present';

View File

@ -1,7 +1,6 @@
/* eslint-disable no-undef */ /* eslint-disable no-undef */
import { TextChannel } from 'eris'; import { TextChannel } from 'eris';
import { Client, RichEmbed } from '../class'; import { Client, RichEmbed } from '../class';
import { MemberInterface } from '../models';
import { CloudServicesUtil } from '../util'; import { CloudServicesUtil } from '../util';
let interval: NodeJS.Timeout; let interval: NodeJS.Timeout;
@ -9,10 +8,10 @@ let interval: NodeJS.Timeout;
export default async function checkLock(client: Client) { export default async function checkLock(client: Client) {
async function start() { async function start() {
try { try {
const moderations = await client.db.Moderation.find(); const moderations = await client.db.mongo.Moderation.find();
const judgements = await client.db.Judgement.find().lean().exec(); const judgements = await client.db.mongo.Judgement.find().lean().exec();
const members = await client.db.Member.find(); const members = await client.db.mongo.Member.find();
members.forEach(async (member: MemberInterface) => { members.forEach(async (member: typeof members[0]) => {
if (member.misc?.t3TemporaryExpiration && member.misc.t3TemporaryExpiration.processed === false) { if (member.misc?.t3TemporaryExpiration && member.misc.t3TemporaryExpiration.processed === false) {
if (new Date() > member.misc.t3TemporaryExpiration.date) { if (new Date() > member.misc.t3TemporaryExpiration.date) {
await CloudServicesUtil.setTier(member.userID, member.misc.t3TemporaryExpiration.previousTier, client.config.internalKey); 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) => { judgements.forEach(async (judgement) => {
if (!judgement.expires) return; if (!judgement.expires) return;
if (new Date() > judgement.expires) { 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 log = <TextChannel> client.guilds.get(client.config.guildID).channels.get('611584771356622849');
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Judgement - Rescind'); embed.setTitle('Judgement - Rescind');

View File

@ -6,15 +6,15 @@ import { Client } from '../class';
let interval: NodeJS.Timeout; let interval: NodeJS.Timeout;
async function setupDepartmentCodes(client: Client): Promise<void> { async function setupDepartmentCodes(client: Client): Promise<void> {
const directorPagers = await client.db.PagerNumber.findOne({ num: '00' }).lean().exec(); const directorPagers = await client.db.mongo.PagerNumber.findOne({ num: '00' }).lean().exec();
const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' }).lean().exec(); const supervisorPagers = await client.db.mongo.PagerNumber.findOne({ num: '01' }).lean().exec();
const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' }).lean().exec(); const technicianPagers = await client.db.mongo.PagerNumber.findOne({ num: '10' }).lean().exec();
const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' }).lean().exec(); const moderatorPagers = await client.db.mongo.PagerNumber.findOne({ num: '20' }).lean().exec();
const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' }).lean().exec(); const coreTeamPagers = await client.db.mongo.PagerNumber.findOne({ num: '21' }).lean().exec();
const associatePagers = await client.db.PagerNumber.findOne({ num: '22' }).lean().exec(); const associatePagers = await client.db.mongo.PagerNumber.findOne({ num: '22' }).lean().exec();
if (!directorPagers) { if (!directorPagers) {
const setup = new client.db.PagerNumber({ const setup = new client.db.mongo.PagerNumber({
num: '00', num: '00',
individualAssignID: '', individualAssignID: '',
emailAddresses: [], emailAddresses: [],
@ -23,7 +23,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
await setup.save(); await setup.save();
} }
if (!supervisorPagers) { if (!supervisorPagers) {
const setup = new client.db.PagerNumber({ const setup = new client.db.mongo.PagerNumber({
num: '01', num: '01',
individualAssignID: '', individualAssignID: '',
emailAddresses: [], emailAddresses: [],
@ -32,7 +32,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
await setup.save(); await setup.save();
} }
if (!technicianPagers) { if (!technicianPagers) {
const setup = new client.db.PagerNumber({ const setup = new client.db.mongo.PagerNumber({
num: '10', num: '10',
individualAssignID: '', individualAssignID: '',
emailAddresses: [], emailAddresses: [],
@ -41,7 +41,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
setup.save(); setup.save();
} }
if (!moderatorPagers) { if (!moderatorPagers) {
const setup = new client.db.PagerNumber({ const setup = new client.db.mongo.PagerNumber({
num: '20', num: '20',
individualAssignID: '', individualAssignID: '',
emailAddresses: [], emailAddresses: [],
@ -50,7 +50,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
await setup.save(); await setup.save();
} }
if (!coreTeamPagers) { if (!coreTeamPagers) {
const setup = new client.db.PagerNumber({ const setup = new client.db.mongo.PagerNumber({
num: '21', num: '21',
individualAssignID: '', individualAssignID: '',
emailAddresses: [], emailAddresses: [],
@ -59,7 +59,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
await setup.save(); await setup.save();
} }
if (!associatePagers) { if (!associatePagers) {
const setup = new client.db.PagerNumber({ const setup = new client.db.mongo.PagerNumber({
num: '22', num: '22',
individualAssignID: '', individualAssignID: '',
emailAddresses: [], emailAddresses: [],
@ -80,46 +80,46 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
async function start(client: Client) { async function start(client: Client) {
async function resolveStaffInformation(id: string) { 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(); await client.guilds.get(client.config.guildID).fetchAllMembers();
const members = client.guilds.get(client.config.guildID).members.map((m) => m); const members = client.guilds.get(client.config.guildID).members.map((m) => m);
for (const member of members) { 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) continue;
if (pager.num.startsWith('00') && !member.roles.includes('662163685439045632')) { 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}` }); await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`); client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff'); await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
} }
if (pager.num.startsWith('01') && !member.roles.includes('701454855952138300')) { 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}` }); await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`); client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff'); await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
} }
if (pager.num.startsWith('10') && !member.roles.includes('701454780828221450')) { 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}` }); await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`); client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff'); await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
} }
if (pager.num.startsWith('20') && !member.roles.includes('455972169449734144')) { 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}` }); await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`); client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff'); await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
} }
if (pager.num.startsWith('21') && !member.roles.includes('453689940140883988')) { 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}` }); await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`); client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff'); await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
} }
if (pager.num.startsWith('22') && !member.roles.includes('701481967149121627')) { 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}` }); await client.util.authClient.deleteUser({ id: `auth0|${member.id}` });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`); client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff'); 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) { 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 // ADD TO ALL STAFF MAILING LIST
if ((member.roles.includes('453689940140883988') || member.roles.includes('701481967149121627')) && !pager) { 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 // eslint-disable-next-line no-constant-condition
while (status) { while (status) {
randomPagerNumber = `00${String(Math.floor(Math.random() * 9) + 1)}`; 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) status = false;
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = await resolveStaffInformation(member.id); const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.mongo.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], 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(); pager = await newNumber.save();
const channel: PrivateChannel = await client.getDMChannel(member.id); 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 // eslint-disable-next-line no-constant-condition
while (status) { while (status) {
randomPagerNumber = `01${String(Math.floor(Math.random() * 9) + 1)}`; 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) status = false;
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = await resolveStaffInformation(member.id); const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.mongo.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], 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(); pager = await newNumber.save();
const channel: PrivateChannel = await client.getDMChannel(member.id); const channel: PrivateChannel = await client.getDMChannel(member.id);
@ -232,19 +232,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
while (status) { while (status) {
randomPagerNumber = `10${String(Math.floor(Math.random() * 99) + 1)}`; randomPagerNumber = `10${String(Math.floor(Math.random() * 99) + 1)}`;
if (randomPagerNumber.length === 3) randomPagerNumber = `${randomPagerNumber}0`; 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) status = false;
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = await resolveStaffInformation(member.id); const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.mongo.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], 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(); pager = await newNumber.save();
const channel: PrivateChannel = await client.getDMChannel(member.id); const channel: PrivateChannel = await client.getDMChannel(member.id);
@ -278,19 +278,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
while (status) { while (status) {
randomPagerNumber = `20${String(Math.floor(Math.random() * 99) + 1)}`; randomPagerNumber = `20${String(Math.floor(Math.random() * 99) + 1)}`;
if (randomPagerNumber.length === 3) randomPagerNumber = `${randomPagerNumber}0`; 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) status = false;
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = await resolveStaffInformation(member.id); const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.mongo.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], 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(); pager = await newNumber.save();
const channel: PrivateChannel = await client.getDMChannel(member.id); const channel: PrivateChannel = await client.getDMChannel(member.id);
@ -324,19 +324,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
while (status) { while (status) {
randomPagerNumber = `21${String(Math.floor(Math.random() * 999) + 1)}`; randomPagerNumber = `21${String(Math.floor(Math.random() * 999) + 1)}`;
if (randomPagerNumber.length === 4) randomPagerNumber = `${randomPagerNumber}0`; 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) status = false;
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = await resolveStaffInformation(member.id); const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.mongo.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], 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(); pager = await newNumber.save();
const channel: PrivateChannel = await client.getDMChannel(member.id); const channel: PrivateChannel = await client.getDMChannel(member.id);
@ -370,19 +370,19 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
while (status) { while (status) {
randomPagerNumber = `22${String(Math.floor(Math.random() * 999) + 1)}`; randomPagerNumber = `22${String(Math.floor(Math.random() * 999) + 1)}`;
if (randomPagerNumber.length === 4) randomPagerNumber = `${randomPagerNumber}0`; 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) status = false;
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = await resolveStaffInformation(member.id); const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.mongo.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], 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(); pager = await newNumber.save();
const channel: PrivateChannel = await client.getDMChannel(member.id); const channel: PrivateChannel = await client.getDMChannel(member.id);
@ -412,7 +412,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
} }
// Associates // 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) { for (const member of members) {
if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) { if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) {
await associatePagers.updateOne({ $addToSet: { discordIDs: 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 // 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) { for (const member of members) {
if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) { if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) {
await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } });
@ -440,7 +440,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
} }
} }
// Moderator // 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) { for (const member of members) {
if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) { if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) {
await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
@ -454,7 +454,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
} }
} }
// Technician // 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) { for (const member of members) {
if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) { if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) {
await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } });
@ -468,7 +468,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
} }
} }
// Supervisor // 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) { for (const member of members) {
if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) { if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) {
await supervisorPagers.updateOne({ $addToSet: { discordIDs: 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 // 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) { for (const member of members) {
if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) { if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) {
await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } });

View File

@ -40,7 +40,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
} }
for (const member of members.values()) { for (const member of members.values()) {
if (member.bot) continue; 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) { if (!score) {
const data: { const data: {
userID: string, userID: string,
@ -69,7 +69,7 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
lastUpdated: new Date(), lastUpdated: new Date(),
pin: [client.util.randomNumber(100, 999), client.util.randomNumber(10, 99), client.util.randomNumber(1000, 9999)], 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}`); 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); roles = Math.floor(member.roles.length * 0.50);
if (roles > 54) roles = 54; 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; let activeMods = 0;
for (const mod of moderations) { for (const mod of moderations) {
if (mod.type === 1 || mod.type === 4) continue; 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); else cloudServices = Math.floor(positives * 0.61);
} }
const inquiries = await client.db.Inquiry.find({ userID: member.user.id, type: 0 }).lean().exec(); const inquiries = await client.db.mongo.Inquiry.find({ userID: member.user.id, type: 0 }).lean().exec();
const judgements = await client.db.Judgement.find({ userID: member.user.id }).lean().exec(); const judgements = await client.db.mongo.Judgement.find({ userID: member.user.id }).lean().exec();
if (inquiries?.length > 0) { if (inquiries?.length > 0) {
for (const inq of inquiries) { 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.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) { 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();
} }
} }
}; };

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View 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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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';

View File

@ -16,9 +16,9 @@ export default class PageDTMF extends Handler {
if (event.application !== 'page-dtmf') return; if (event.application !== 'page-dtmf') return;
const message = await (<TextableChannel> this.client.guilds.get(this.client.config.guildID).channels.get('501089664040697858')).getMessage('775604192013320203'); const message = await (<TextableChannel> this.client.guilds.get(this.client.config.guildID).channels.get('501089664040697858')).getMessage('775604192013320203');
if (!message) return Misc.accessDenied(channel); 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); 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); if (!pager) return Misc.accessDenied(channel);
let status = 0; let status = 0;
const pagerNumber: string[] = []; const pagerNumber: string[] = [];

10636
yarn.lock

File diff suppressed because it is too large Load Diff