Compare commits

..

21 Commits
ctx ... master

Author SHA1 Message Date
Matthew 22b5421010
Merge branch 'dev'
# Conflicts:
#	package.json
2024-11-25 02:04:36 -05:00
Matthew 96e1ecdafb
verbiage changes 2024-11-25 02:00:23 -05:00
Matthew 87d7ac31aa
verbiage changes 2024-11-25 01:56:13 -05:00
Matthew 3736469b31 update author to reflect current 2023-02-23 16:16:45 -05:00
Matthew 77213c0178 commit package-lock.json 2023-02-23 16:12:13 -05:00
Matthew d5f0346f75 Merge branch 'dev' 2023-02-21 13:09:42 -05:00
Matthew b124b70f87 push coding changes reflecting organizational structure changes (v2) 2023-02-21 13:09:00 -05:00
Matthew 9074f85fbb push coding changes reflecting organizational structure changes 2023-02-21 12:56:48 -05:00
Matthew 3cd15fcdad remove redundant variables 2023-02-16 13:32:30 -05:00
Matthew 1dba55f0a6 changes to eslint and update deps 2023-02-16 13:24:59 -05:00
Matthew ae9be3ae11 Merge remote-tracking branch 'origin/dev' into dev 2023-02-16 13:22:49 -05:00
Matthew e66b54ad96 add semicolons to calculatereport call 2023-02-16 13:22:27 -05:00
Matthew 743d98acf7 Merge branch 'dev' of gitlab.libraryofcode.org:engineering/community-relations/backend into dev 2023-02-15 21:04:45 -05:00
Matthew 7a1caddcdc push new cmds 2023-02-15 21:04:34 -05:00
Matthew 9e6d19897c change apply run func 2023-02-15 09:41:23 -05:00
Matthew 81e7f3cc14 update eval code 2023-02-12 13:16:04 -05:00
Matthew 4f07d6ece2 wait for mongoose to connect 2023-02-12 00:36:22 -05:00
Matthew d696dcf804 update deps x2 2023-02-11 23:59:07 -05:00
Matthew bb039360a0 add ctx handling to command handler 2023-02-11 23:57:50 -05:00
Matthew 903f918678 Merge branch 'ctx' into dev 2023-02-11 23:52:10 -05:00
Matthew ab88fcfd58
changes 2022-10-10 16:05:35 -04:00
32 changed files with 382 additions and 294 deletions

View File

@ -43,7 +43,8 @@
"consistent-return": "off", "consistent-return": "off",
"no-continue": "off", "no-continue": "off",
"no-plusplus": "off", "no-plusplus": "off",
"no-undef": "off" "no-undef": "off",
"space-before-function-paren": "off"
}, },
"ignorePatterns": "**/*.js" "ignorePatterns": "**/*.js"
} }

128
package-lock.json generated
View File

@ -27,7 +27,7 @@
"express": "^4.17.1", "express": "^4.17.1",
"helmet": "^4.6.0", "helmet": "^4.6.0",
"ioredis": "^4.28.2", "ioredis": "^4.28.2",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^9.0.0",
"mathjs": "^10.0.0", "mathjs": "^10.0.0",
"moment": "^2.29.1", "moment": "^2.29.1",
"mongoose": "^6.1.1", "mongoose": "^6.1.1",
@ -2298,6 +2298,54 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/auth0/node_modules/jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"dependencies": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
},
"engines": {
"node": ">=4",
"npm": ">=1.4.28"
}
},
"node_modules/auth0/node_modules/jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"dependencies": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/auth0/node_modules/jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"dependencies": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/auth0/node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/available-typed-arrays": { "node_modules/available-typed-arrays": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
@ -5147,24 +5195,18 @@
} }
}, },
"node_modules/jsonwebtoken": { "node_modules/jsonwebtoken": {
"version": "8.5.1", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", "integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==",
"dependencies": { "dependencies": {
"jws": "^3.2.2", "jws": "^3.2.2",
"lodash.includes": "^4.3.0", "lodash": "^4.17.21",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1", "ms": "^2.1.1",
"semver": "^5.6.0" "semver": "^7.3.8"
}, },
"engines": { "engines": {
"node": ">=4", "node": ">=12",
"npm": ">=1.4.28" "npm": ">=6"
} }
}, },
"node_modules/jsonwebtoken/node_modules/jwa": { "node_modules/jsonwebtoken/node_modules/jwa": {
@ -5186,14 +5228,6 @@
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
}, },
"node_modules/jsonwebtoken/node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/jsprim": { "node_modules/jsprim": {
"version": "1.4.2", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
@ -5243,6 +5277,54 @@
"follow-redirects": "^1.14.0" "follow-redirects": "^1.14.0"
} }
}, },
"node_modules/jwks-rsa/node_modules/jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"dependencies": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
},
"engines": {
"node": ">=4",
"npm": ">=1.4.28"
}
},
"node_modules/jwks-rsa/node_modules/jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"dependencies": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jwks-rsa/node_modules/jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"dependencies": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jwks-rsa/node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/jws": { "node_modules/jws": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz",
@ -6356,7 +6438,7 @@
"version": "17.1.3", "version": "17.1.3",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-17.1.3.tgz", "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-17.1.3.tgz",
"integrity": "sha512-tVtvNSOOqlq75rUgwLeDAEQoLIiBqmRg0/zedpI6fuqIocIkuxG23A7FIl1oVSkuSMMLgcOP5kVhNETmsmjvPw==", "integrity": "sha512-tVtvNSOOqlq75rUgwLeDAEQoLIiBqmRg0/zedpI6fuqIocIkuxG23A7FIl1oVSkuSMMLgcOP5kVhNETmsmjvPw==",
"deprecated": "< 18.1.0 is no longer supported", "deprecated": "< 19.2.0 is no longer supported",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"cross-fetch": "3.1.5", "cross-fetch": "3.1.5",

View File

@ -16,8 +16,8 @@
"@types/cron": "^1.7.3", "@types/cron": "^1.7.3",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/helmet": "^0.0.48", "@types/helmet": "^0.0.48",
"@types/jsonwebtoken": "^8.5.6",
"@types/ioredis": "4.28.10", "@types/ioredis": "4.28.10",
"@types/jsonwebtoken": "^8.5.6",
"@types/node": "^16.11.12", "@types/node": "^16.11.12",
"@types/nodemailer": "^6.4.4", "@types/nodemailer": "^6.4.4",
"@types/puppeteer": "^5.4.4", "@types/puppeteer": "^5.4.4",
@ -50,7 +50,7 @@
"express": "^4.17.1", "express": "^4.17.1",
"helmet": "^4.6.0", "helmet": "^4.6.0",
"ioredis": "^4.28.2", "ioredis": "^4.28.2",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^9.0.0",
"mathjs": "^10.0.0", "mathjs": "^10.0.0",
"moment": "^2.29.1", "moment": "^2.29.1",
"mongoose": "^6.1.1", "mongoose": "^6.1.1",

View File

@ -82,7 +82,7 @@ export default class Root extends Route {
${payload.body} ${payload.body}
_____________________________________________________________________ _____________________________________________________________________
LIBRARY OF CODE SP-US | BOARD OF DIRECTORS LIBRARY OF CODE INC | BOARD OF DIRECTORS
BOARD REGISTER SYSTEM https://board.ins/ BOARD REGISTER SYSTEM https://board.ins/
`, `,
}); });
@ -118,7 +118,7 @@ export default class Root extends Route {
${payload.body} ${payload.body}
_____________________________________________________________________ _____________________________________________________________________
LIBRARY OF CODE SP-US | BOARD OF DIRECTORS LIBRARY OF CODE INC | BOARD OF DIRECTORS
BOARD REGISTER SYSTEM https://board.ins/ BOARD REGISTER SYSTEM https://board.ins/
`, `,
}); });
@ -140,7 +140,7 @@ export default class Root extends Route {
embed.addField('Subject', payload.subject); embed.addField('Subject', payload.subject);
embed.addField('Body', payload.body); embed.addField('Body', payload.body);
embed.setColor(color); embed.setColor(color);
embed.setFooter('Library of Code sp-us | Board Register System', 'https://static.libraryofcode.org/library_of_code.png'); embed.setFooter('Library of Code Inc | Board Register System', 'https://static.libraryofcode.org/library_of_code.png');
embed.setTimestamp(); embed.setTimestamp();
return embed; return embed;

View File

@ -449,7 +449,7 @@ export default class Report extends Route {
updated = true; updated = true;
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);
} else { } else {
await this.server.client.report.createInquiry(member.user.id, 'Library of Code sp-us | Staff Team via report.libraryofcode.org', 1); await this.server.client.report.createInquiry(member.user.id, 'Library of Code Inc | Staff Team via report.libraryofcode.org', 1);
} }
} 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);

View File

@ -77,8 +77,7 @@ export default class Client extends eris.Client {
} }
public async loadDatabase() { public async loadDatabase() {
mongoose.connect(this.config.mongoDB, { await mongoose.connect(this.config.mongoDB, {
minPoolSize: 50,
}); });
const statMessages = await this.db.mongo.Stat.findOne({ name: 'messages' }); const statMessages = await this.db.mongo.Stat.findOne({ name: 'messages' });

View File

@ -26,13 +26,13 @@ export default class Command {
/** /**
* - **0:** Everyone * - **0:** Everyone
* - **1:** Associates+ * - **1:** Core Team, Staff in Training, and ++
* - **2:** Core Team+ * - **2:** Core Team+
* - **3:** Moderators, Supervisor, & Board of Directors * - **3:** Moderators and Department Heads
* - **4:** Technicians, Supervisor, & Board of Directors * - **4:** Technicians and Department Heads
* - **5:** Moderators, Technicians, Supervisor, & Board of Directors * - **5:** Moderators, Technicians, and Management
* - **6:** Supervisor+ * - **6:** Management
* - **7:** Board of Directors * - **7:** Department Heads
*/ */
public permissions: number; public permissions: number;
@ -74,19 +74,19 @@ export default class Command {
case 0: case 0:
return true; return true;
case 1: case 1:
return member.roles.some((r) => ['701481967149121627', '453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['701481967149121627', '453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '1077646568091570236'].includes(r));
case 2: case 2:
return member.roles.some((r) => ['453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '1077646568091570236'].includes(r));
case 3: case 3:
return member.roles.some((r) => ['455972169449734144', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['455972169449734144', '1077646956890951690', '1077647072163020840'].includes(r));
case 4: case 4:
return member.roles.some((r) => ['701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['701454780828221450', '1077646956890951690', '1077647072163020840'].includes(r));
case 5: case 5:
return member.roles.some((r) => ['455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['455972169449734144', '701454780828221450', '1077646568091570236'].includes(r));
case 6: case 6:
return member.roles.some((r) => ['701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['1077646568091570236'].includes(r));
case 7: case 7:
return member.roles.includes('662163685439045632'); return member.roles.some((r) => ['1077646956890951690', '1077647072163020840'].includes(r));
default: default:
return false; return false;
} }
@ -98,19 +98,19 @@ export default class Command {
case 0: case 0:
return true; return true;
case 1: case 1:
return member.roles.some((r) => ['701481967149121627', '453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['701481967149121627', '453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '1077646568091570236'].includes(r));
case 2: case 2:
return member.roles.some((r) => ['453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['453689940140883988', '455972169449734144', '701454780828221450', '701454855952138300', '1077646568091570236'].includes(r));
case 3: case 3:
return member.roles.some((r) => ['455972169449734144', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['455972169449734144', '1077646956890951690', '1077647072163020840'].includes(r));
case 4: case 4:
return member.roles.some((r) => ['701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['701454780828221450', '1077646956890951690', '1077647072163020840'].includes(r));
case 5: case 5:
return member.roles.some((r) => ['455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['455972169449734144', '701454780828221450', '1077646568091570236'].includes(r));
case 6: case 6:
return member.roles.some((r) => ['701454855952138300', '662163685439045632'].includes(r)); return member.roles.some((r) => ['1077646568091570236'].includes(r));
case 7: case 7:
return member.roles.includes('662163685439045632'); return member.roles.some((r) => ['1077646956890951690', '1077647072163020840'].includes(r));
default: default:
return false; return false;
} }

View File

@ -24,7 +24,7 @@ export default class Queue {
} }
protected setCronJobs() { protected setCronJobs() {
const historialCommunityReportJob = new cron.CronJob('0 20 * * *', async () => { const historicalCommunityReportJob = new cron.CronJob('0 20 * * *', async () => {
try { try {
const reports = await this.client.db.mongo.Score.find().lean().exec(); const reports = await this.client.db.mongo.Score.find().lean().exec();
const startDate = new Date(); const startDate = new Date();
@ -78,10 +78,10 @@ export default class Queue {
members.forEach(async member => { members.forEach(async member => {
const resolvedMember = await this.client.getRESTGuildMember(this.client.config.guildID, member.id); const resolvedMember = await this.client.getRESTGuildMember(this.client.config.guildID, member.id);
calculateReport(this.client, resolvedMember, [...general, ...programmingSupport, ...programmingSupport2, ...cloudSupport, ...projectMessages]) calculateReport(this.client, resolvedMember, [...general, ...programmingSupport, ...programmingSupport2, ...cloudSupport, ...projectMessages])
}) });
}) });
historialCommunityReportJob.start(); historicalCommunityReportJob.start();
clearOldHistoricalReportsJob.start(); clearOldHistoricalReportsJob.start();
calculateScores.start(); calculateScores.start();
} }

View File

@ -13,7 +13,7 @@ export default class Server {
public port: number; public port: number;
private root: string; private readonly root: string;
protected parse: boolean; protected parse: boolean;

View File

@ -5,7 +5,7 @@
import PhoneNumber from 'awesome-phonenumber'; import PhoneNumber from 'awesome-phonenumber';
import axios from 'axios'; import axios from 'axios';
import { Message, TextChannel } from 'eris'; import { Message, TextChannel } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Callback extends Command { export default class Callback extends Command {
constructor(client: Client) { constructor(client: Client) {
@ -19,7 +19,7 @@ export default class Callback extends Command {
this.enabled = false; this.enabled = false;
} }
public async run(message: Message, args: string[]) { public async run(ctx: CmdContext) {
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]);
if (message.channel.type === 0) await message.delete(); if (message.channel.type === 0) await message.delete();
const member = this.mainGuild.members.get(message.author.id); const member = this.mainGuild.members.get(message.author.id);
@ -34,7 +34,7 @@ export default class Callback extends Command {
embed.addField('Phone Number Type', phone.getType(), true); embed.addField('Phone Number Type', phone.getType(), true);
const communityReport = await this.client.db.mongo.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 Inc | 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);
} }
try { try {

View File

@ -60,6 +60,6 @@ export default class Eval extends Command {
} }
} }
return display.forEach((m) => ctx.message.channel.createMessage(`\`\`\`js\n${m}\n\`\`\``)); return display.forEach((m) => ctx.uniCreateMessage(`\`\`\`js\n${m}\n\`\`\``));
} }
} }

View File

@ -3,7 +3,7 @@
*/ */
/* eslint-disable prefer-destructuring */ /* eslint-disable prefer-destructuring */
import { Activity, Member, Message } from 'eris'; import { Activity, Member, Message } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, CmdContext, Command, RichEmbed } from '../class';
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
enum ActivityType { enum ActivityType {
@ -26,7 +26,7 @@ export default class Game extends Command {
this.enabled = false; this.enabled = false;
} }
public async run(message: Message, args: string[]) { public async run(ctx: CmdContext) {
let member: Member; let member: Member;
if (!args[0]) member = message.member; if (!args[0]) member = message.member;
else { else {

View File

@ -19,7 +19,7 @@ export default class Info extends Command {
embed.setTitle('Information'); embed.setTitle('Information');
embed.setThumbnail(this.client.user.avatarURL); embed.setThumbnail(this.client.user.avatarURL);
embed.setDescription(`*See \`${this.client.config.prefix}sysinfo\` for more information on libraries used by this application.*`); embed.setDescription(`*See \`${this.client.config.prefix}sysinfo\` for more information on libraries used by this application.*`);
embed.addField('Developers', 'Library of Code | Dept. of Engineering & other contributors', true); embed.addField('Developers', 'Library of Code, Inc. | Dept. of Engineering & other contributors', true);
embed.addField('Version', 'Rolling Release', true); embed.addField('Version', 'Rolling Release', true);
embed.addField('Language(s)', '<:TypeScript:703451285789343774> TypeScript', true); embed.addField('Language(s)', '<:TypeScript:703451285789343774> TypeScript', true);
embed.addField('Runtime', `Node (${process.version})`, true); embed.addField('Runtime', `Node (${process.version})`, true);

View File

@ -30,7 +30,7 @@ export default class Inquiry extends Command {
const { report } = inquiry; const { report } = inquiry;
// if (!report) return this.error(message.channel, 'Could not find inquiry information.'); // if (!report) return this.error(message.channel, 'Could not find inquiry information.');
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 Inc | Bureau of Community Reports', 1);
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle(`Hard Inquiry Information - ${inquiry.iid}`); embed.setTitle(`Hard Inquiry Information - ${inquiry.iid}`);

View File

@ -3,7 +3,7 @@
*/ */
import { Message } from 'eris'; import { Message } from 'eris';
import { Client, Command } from '../class'; import { Client, CmdContext, Command } from '../class';
import { Misc as MiscPBXActions } from '../pbx'; import { Misc as MiscPBXActions } from '../pbx';
export default class Intercom extends Command { export default class Intercom extends Command {
@ -17,7 +17,7 @@ export default class Intercom extends Command {
this.enabled = false; this.enabled = false;
} }
public async run(message: Message, args: string[]) { public async run(ctx: CmdContext) {
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 loading = await this.loading(message.channel, 'Synthesizing text...'); const loading = await this.loading(message.channel, 'Synthesizing text...');

View File

@ -5,7 +5,7 @@
/* eslint-disable default-case */ /* eslint-disable default-case */
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import { Message } from 'eris'; import { Message } from 'eris';
import { Client, Command } from '../class'; import { Client, CmdContext, Command } from '../class';
export default class Offer extends Command { export default class Offer extends Command {
constructor(client: Client) { constructor(client: Client) {
@ -19,7 +19,7 @@ export default class Offer extends Command {
this.enabled = false; this.enabled = false;
} }
public async run(message: Message, args: string[]) { public async run(ctx: CmdContext) {
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.');

View File

@ -89,7 +89,7 @@ export default class StaffAssistedApplication extends Command {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
notificationEmbed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`); notificationEmbed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`);
notificationEmbed.addField('Decision', 'PROCESSING'); notificationEmbed.addField('Decision', 'PROCESSING');
notificationEmbed.addField('Initiated by', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code sp-us*`); notificationEmbed.addField('Initiated by', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code Inc*`);
notificationEmbed.addField('Application ID', application.id); notificationEmbed.addField('Application ID', application.id);
notificationEmbed.addField('Service Code', ctx.args[1]); notificationEmbed.addField('Service Code', ctx.args[1]);
notificationEmbed.setFooter(this.client.user.username, this.client.user.avatarURL); notificationEmbed.setFooter(this.client.user.username, this.client.user.avatarURL);

View File

@ -38,7 +38,7 @@ export default class SAA_Approve extends Command {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
embed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`); embed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`);
embed.addField('Decision', 'APPROVED'); embed.addField('Decision', 'APPROVED');
embed.addField('Underwriter', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code sp-us*`); embed.addField('Underwriter', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code Inc*`);
embed.addField('Application ID', saa.applicationID); embed.addField('Application ID', saa.applicationID);
embed.addField('Service Code', saa.serviceCode); embed.addField('Service Code', saa.serviceCode);
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);

View File

@ -35,7 +35,7 @@ export default class SAA_Decline extends Command {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
embed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`); embed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`);
embed.addField('Decision', 'DECLINED'); embed.addField('Decision', 'DECLINED');
embed.addField('Underwriter', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code sp-us*`); embed.addField('Underwriter', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code Inc*`);
embed.addField('Application ID', saa.applicationID); embed.addField('Application ID', saa.applicationID);
embed.addField('Service Code', saa.serviceCode); embed.addField('Service Code', saa.serviceCode);
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);

View File

@ -14,7 +14,7 @@ export default class Score extends Command {
super(client); super(client);
this.name = 'score'; this.name = 'score';
this.description = 'Retrieves your Community Report'; this.description = 'Retrieves your Community Report';
this.usage = `${this.client.config.prefix}score\n${this.client.config.prefix}score <member> <type: 'hard' | 'soft'> <reporting department: ex. Library of Code sp-us | Cloud Account Services>:<reason>`; this.usage = `${this.client.config.prefix}score\n${this.client.config.prefix}score <member> <type: 'hard' | 'soft'> <reporting department: ex. Library of Code Inc | Cloud Account Services>:<reason>`;
this.aliases = ['report']; this.aliases = ['report'];
this.subcmds = [Score_Hist, Score_Notify, Score_Pref]; this.subcmds = [Score_Hist, Score_Notify, Score_Pref];
this.permissions = 0; this.permissions = 0;
@ -181,7 +181,7 @@ export default class Score extends Command {
let name = ''; let name = '';
// eslint-disable-next-line no-unreachable-loop // eslint-disable-next-line no-unreachable-loop
for (const role of this.client.util.resolveMember(ctx.message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) { for (const role of this.client.util.resolveMember(ctx.message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
name = `Library of Code sp-us | ${role.name}`; name = `Library of Code Inc | ${role.name}`;
break; break;
} }
await this.client.report.createInquiry(user.id, name, 1); await this.client.report.createInquiry(user.id, name, 1);

View File

@ -34,7 +34,7 @@ export default class Score_Hist extends Command {
let name = ''; let name = '';
// eslint-disable-next-line no-unreachable-loop // eslint-disable-next-line no-unreachable-loop
for (const role of this.client.util.resolveMember(ctx.message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) { for (const role of this.client.util.resolveMember(ctx.message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
name = `Library of Code sp-us | ${role.name} - [HISTORICAL]`; name = `Library of Code Inc | ${role.name} - [HISTORICAL]`;
break; break;
} }
await this.client.report.createInquiry(user.id, name, 1); await this.client.report.createInquiry(user.id, name, 1);

View File

@ -4,7 +4,7 @@
import { Message, GuildTextableChannel } from 'eris'; import { Message, GuildTextableChannel } from 'eris';
import moment, { unitOfTime } from 'moment'; import moment, { unitOfTime } from 'moment';
import { Client, Command } from '../class'; import { Client, CmdContext, Command } from '../class';
export default class Slowmode extends Command { export default class Slowmode extends Command {
regex: RegExp; regex: RegExp;
@ -20,7 +20,7 @@ export default class Slowmode extends Command {
this.regex = /[a-z]+|[^a-z]+/gi; this.regex = /[a-z]+|[^a-z]+/gi;
} }
public async run(message: Message<GuildTextableChannel>, args: string[]) { public async run(ctx: CmdContext) {
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 [length, unit] = args[0].match(this.regex); const [length, unit] = args[0].match(this.regex);

View File

@ -4,7 +4,7 @@
import { Message } from 'eris'; import { Message } from 'eris';
import { apply as Apply } from '.'; import { apply as Apply } from '.';
import { Client, Command } from '../class'; import { Client, CmdContext, Command } from '../class';
export default class SSS_Create_Account extends Command { export default class SSS_Create_Account extends Command {
public applyCommand: Apply; public applyCommand: Apply;
@ -19,7 +19,7 @@ export default class SSS_Create_Account extends Command {
this.enabled = false; this.enabled = false;
} }
public async run(message: Message) { public async run(ctx: CmdContext) {
try { try {
const staff = await this.client.db.mongo.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.');
@ -110,7 +110,7 @@ export default class SSS_Create_Account extends Command {
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
const channel = await this.client.getDMChannel(message.author.id); const channel = await this.client.getDMChannel(message.author.id);
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(message.channel, 'Unable to send you a DM.')); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(message.channel, 'Unable to send you a DM.'));
return message.addReaction('modSuccess:578750988907970567'); return message.addReaction('modSuccess:578750988907970567');
} catch (err) { } catch (err) {
return this.client.util.handleError(err, message, this); return this.client.util.handleError(err, message, this);

View File

@ -24,7 +24,7 @@ export default class SSS_Password_Reset extends Command {
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
const channel = await this.client.getDMChannel(ctx.message.author.id); const channel = await this.client.getDMChannel(ctx.message.author.id);
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(ctx.message.channel, 'Unable to send you a DM.')); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(ctx.message.channel, 'Unable to send you a DM.'));
return ctx.message.addReaction('modSuccess:578750988907970567'); return ctx.message.addReaction('modSuccess:578750988907970567');
} catch (err) { } catch (err) {
return this.client.util.handleError(err, ctx.message, this); return this.client.util.handleError(err, ctx.message, this);

View File

@ -4,7 +4,7 @@
import { randomBytes } from 'crypto'; import { randomBytes } from 'crypto';
import { Message, TextChannel } from 'eris'; import { Message, TextChannel } from 'eris';
import { Client, Command, LocalStorage } from '../class'; import { Client, CmdContext, Command, LocalStorage } from '../class';
export default class StoreMessages extends Command { export default class StoreMessages extends Command {
constructor(client: Client) { constructor(client: Client) {
@ -18,7 +18,7 @@ export default class StoreMessages extends Command {
this.enabled = false; this.enabled = false;
} }
public async run(message: Message, args: string[]) { public async run(ctx: CmdContext) {
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 = this.client.util.resolveGuildChannel(args[0], this.mainGuild, false); const check = this.client.util.resolveGuildChannel(args[0], this.mainGuild, false);
if (!check || check.type !== 0) return this.error(message.channel, 'The channel you specified either doesn\'t exist or isn\'t a textable guild channel.'); if (!check || check.type !== 0) return this.error(message.channel, 'The channel you specified either doesn\'t exist or isn\'t a textable guild channel.');

View File

@ -85,7 +85,7 @@ export default class Whois extends Command {
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.mongo.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 Inc | Bureau of Community Reports', 1);
let totalScore = '0'; let totalScore = '0';
if (score.total < 200) totalScore = '---'; if (score.total < 200) totalScore = '---';
else if (score.total > 800) totalScore = '800'; else if (score.total > 800) totalScore = '800';
@ -231,7 +231,7 @@ export default class Whois extends Command {
if (ackResolve?.additionalRoles?.length > 0) { if (ackResolve?.additionalRoles?.length > 0) {
embed.addField('Additional Acknowledgements', ackResolve.additionalRoles.join(', ')); embed.addField('Additional Acknowledgements', ackResolve.additionalRoles.join(', '));
} }
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(`Library of Code, Inc.`, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
return ctx.uniCreateMessage({ embed }); return ctx.uniCreateMessage({ embed });
} }

View File

@ -1,7 +1,7 @@
/* eslint-disable no-useless-return */ /* eslint-disable no-useless-return */
import { Message, TextChannel, NewsChannel } from 'eris'; import { Message, TextChannel, NewsChannel } from 'eris';
import * as Sentry from '@sentry/node'; import * as Sentry from '@sentry/node';
import { Client, Event } from '../class'; import { Client, CmdContext, Event } from '../class';
export default class CommandHandler extends Event { export default class CommandHandler extends Event {
public client: Client; public client: Client;
@ -29,7 +29,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}'.`);
try { try {
const span = transaction.startChild({ op: 'Command.run' }); const span = transaction.startChild({ op: 'Command.run' });
await resolved.cmd.run(message, resolved.args); await resolved.cmd.run(new CmdContext(message, resolved.args));
span.finish(); span.finish();
} catch (err) { } catch (err) {
this.client.util.handleError(err, message, resolved.cmd); this.client.util.handleError(err, message, resolved.cmd);

View File

@ -125,7 +125,7 @@ export default class MessageReactionAdd extends Event {
_____________________________________________________________________ _____________________________________________________________________
LIBRARY OF CODE SP-US | BOARD OF DIRECTORS LIBRARY OF CODE INC | BOARD OF DIRECTORS
BOARD REGISTER SYSTEM https://board.ins/ BOARD REGISTER SYSTEM https://board.ins/
`, `,
}); });
@ -136,4 +136,3 @@ export default class MessageReactionAdd extends Event {
} }
} }
} }

View File

@ -3,20 +3,20 @@ import { Client } from '../class';
import { CloudServicesUtil } from '../util'; import { CloudServicesUtil } from '../util';
export function getTotalMessageCount(client: Client): number { export function getTotalMessageCount(client: Client): number {
const projectChannels: TextChannel[] = []; const projectChannels: TextChannel[] = [];
for (const c of client.guilds.get(client.config.guildID).channels.filter((ch) => ch.type === 0)) { for (const c of client.guilds.get(client.config.guildID).channels.filter((ch) => ch.type === 0)) {
const chan = <TextChannel> c; const chan = <TextChannel> c;
if (chan.parentID !== '701591772186411108') continue; if (chan.parentID !== '701591772186411108') continue;
projectChannels.push(chan); projectChannels.push(chan);
}
return (projectChannels.length * 200) + 2200 + 300 + 100 + 200;
} }
return (projectChannels.length * 200) + 2200 + 300 + 100 + 200;
}
export default async function(client: Client, member: Member, allMessagesArray: Message<TextChannel>[]) { export default async function calculateReport(client: Client, member: Member, allMessagesArray: Message<TextChannel>[]) {
if (member.bot) return; if (member.bot) return;
let score = await client.db.mongo.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,
total: number, total: number,
activity: number, activity: number,
@ -43,127 +43,132 @@ export default async function(client: Client, member: Member, allMessagesArray:
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.mongo.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}`);
} }
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
// eslint-disable-next-line one-var-declaration-per-line // eslint-disable-next-line one-var-declaration-per-line
// eslint-disable-next-line one-var // eslint-disable-next-line one-var
let total = 0, activity = 0, roles = 0, moderation = 0, cloudServices = 0, other = 0, staff = 0; let total = 0,
cloudServices = 0; activity = 0,
roles = 0,
moderation = 0,
cloudServices = 0,
other = 0,
staff = 0;
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.mongo.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;
const testDate = (new Date(new Date(mod.date).setHours(2190))); const testDate = (new Date(new Date(mod.date).setHours(2190)));
if (testDate > new Date()) { moderation -= 15; activeMods++; } if (testDate > new Date()) { moderation -= 15; activeMods++; }
} }
if (activeMods <= 0) moderation = 2; if (activeMods <= 0) moderation = 2;
let messageCountTotal = 0; let messageCountTotal = 0;
for (const msg of allMessagesArray.filter((m) => m.member?.id === member.id)) { for (const msg of allMessagesArray.filter((m) => m.member?.id === member.id)) {
if (!msg.content) continue; if (!msg.content) continue;
if (msg.content.length <= 5) continue; if (msg.content.length <= 5) continue;
// eslint-disable-next-line no-plusplus // eslint-disable-next-line no-plusplus
messageCountTotal++; messageCountTotal++;
} }
const activityTotal = messageCountTotal; const activityTotal = messageCountTotal;
activity = Math.floor(Math.log1p(activityTotal) * 12); activity = Math.floor(Math.log1p(activityTotal) * 12);
if (activity > (Math.log1p(getTotalMessageCount(client)) * 12)) activity = Math.floor((Math.log1p(getTotalMessageCount(client)) * 12)); if (activity > (Math.log1p(getTotalMessageCount(client)) * 12)) activity = Math.floor((Math.log1p(getTotalMessageCount(client)) * 12));
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) staff += 5; if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) staff += 5;
const response = await CloudServicesUtil.fetchAccountStatus(member.user.id, client.config.internalKey); const response = await CloudServicesUtil.fetchAccountStatus(member.user.id, client.config.internalKey);
if (response || response?.found === true) { if (response || response?.found === true) {
let negatives = 0; let negatives = 0;
let positives = 0; let positives = 0;
if (response.createdAt) { if (response.createdAt) {
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730))); const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
if (csCreatedTestDate > new Date()) { if (csCreatedTestDate > new Date()) {
negatives -= 10; negatives -= 10;
}
}
let warns = 0;
for (const warn of response.warns) {
const date = (new Date(new Date(warn).setHours(730)));
if (date > new Date()) { negatives -= 2; warns++; }
}
if (warns <= 0) positives += 2;
if (response.warns.length === 0) positives += 3;
let locks = 0;
for (const lock of response.locks) {
const date = (new Date(new Date(lock).setHours(1460)));
if (date > new Date()) { negatives -= 5; locks++; }
}
if (locks <= 0) positives += 3;
if (response.locks.length === 0) positives += 7;
if (response.deletes.length > 0) {
for (const del of response.deletes) {
const date = (new Date(new Date(del).setHours(3650)));
if (date > new Date()) negatives -= 20;
}
}
positives += Math.floor(response.totalReferrals * 1.17);
if (response.tier === 2) positives += 2;
else if (response.tier === 3) positives += 3;
if (negatives < 0) cloudServices = Math.floor((negatives * 1.2) + (positives * 0.06));
else cloudServices = Math.floor(positives * 0.61);
}
const inquiries = await client.db.mongo.Inquiry.find({ userID: member.user.id, type: 0 }).lean().exec();
const judgements = await client.db.mongo.Judgement.find({ userID: member.user.id }).lean().exec();
if (inquiries?.length > 0) {
for (const inq of inquiries) {
const testDate = (new Date(new Date(inq.date).setHours(1460)));
if (testDate > new Date()) other -= 1.65;
}
other = Math.floor(other * 1.15);
}
if (judgements?.length > 0) {
for (const judgement of judgements) {
switch (judgement.severity) {
// eslint-disable-next-line default-case-last
default:
break;
case 0:
other -= 5;
break;
case 1:
other -= 10;
break;
case 2:
other -= 20;
break;
}
} }
} }
let warns = 0;
const discordAccountCreatedAtTestDate = (new Date(new Date(new Date(member.user.createdAt)).setHours(730))); for (const warn of response.warns) {
if (discordAccountCreatedAtTestDate > new Date()) { const date = (new Date(new Date(warn).setHours(730)));
other -= 10; if (date > new Date()) { negatives -= 2; warns++; }
} }
if (warns <= 0) positives += 2;
if (response.warns.length === 0) positives += 3;
const joinedAtTestDate = (new Date(new Date(new Date(member.joinedAt)).setHours(420))); let locks = 0;
if (joinedAtTestDate > new Date()) { for (const lock of response.locks) {
other -= 30; const date = (new Date(new Date(lock).setHours(1460)));
if (date > new Date()) { negatives -= 5; locks++; }
} }
if (locks <= 0) positives += 3;
if (response.locks.length === 0) positives += 7;
total = Math.floor(((total + activity + roles + moderation + cloudServices + staff + other) * 5.13) * 1.87); if (response.deletes.length > 0) {
for (const del of response.deletes) {
// client.queue.updateScore(score, total, activity, roles, moderation, cloudServices, other, staff); const date = (new Date(new Date(del).setHours(3650)));
if (date > new Date()) negatives -= 20;
client.db.mongo.Score.updateOne({ userID: score.userID }, { $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } }).exec(); }
if (!score.pin || score.pin?.length < 1) {
client.db.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();
} }
positives += Math.floor(response.totalReferrals * 1.17);
if (response.tier === 2) positives += 2;
else if (response.tier === 3) positives += 3;
if (negatives < 0) cloudServices = Math.floor((negatives * 1.2) + (positives * 0.06));
else cloudServices = Math.floor(positives * 0.61);
}
const inquiries = await client.db.mongo.Inquiry.find({ userID: member.user.id, type: 0 }).lean().exec();
const judgements = await client.db.mongo.Judgement.find({ userID: member.user.id }).lean().exec();
if (inquiries?.length > 0) {
for (const inq of inquiries) {
const testDate = (new Date(new Date(inq.date).setHours(1460)));
if (testDate > new Date()) other -= 1.65;
}
other = Math.floor(other * 1.15);
}
if (judgements?.length > 0) {
for (const judgement of judgements) {
switch (judgement.severity) {
// eslint-disable-next-line default-case-last
default:
break;
case 0:
other -= 5;
break;
case 1:
other -= 10;
break;
case 2:
other -= 20;
break;
}
}
}
const discordAccountCreatedAtTestDate = (new Date(new Date(new Date(member.user.createdAt)).setHours(730)));
if (discordAccountCreatedAtTestDate > new Date()) {
other -= 10;
}
const joinedAtTestDate = (new Date(new Date(new Date(member.joinedAt)).setHours(420)));
if (joinedAtTestDate > new Date()) {
other -= 30;
}
total = Math.floor(((total + activity + roles + moderation + cloudServices + staff + other) * 5.13) * 1.87);
// client.queue.updateScore(score, total, activity, roles, moderation, cloudServices, other, staff);
client.db.mongo.Score.updateOne({ userID: score.userID }, { $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } }).exec();
if (!score.pin || score.pin?.length < 1) {
client.db.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

@ -24,6 +24,6 @@ export default class Apply extends InteractionCommand {
public async run(interaction: CommandInteraction) { public async run(interaction: CommandInteraction) {
console.log(interaction.data); console.log(interaction.data);
interaction.createMessage('HELP ME PLEASE'); interaction.createMessage('.');
} }
} }

View File

@ -62,6 +62,7 @@ export default async function checkLock(client: Client) {
await start(); await start();
interval = setInterval(async () => { interval = setInterval(async () => {
await start(); await start();
}, 10000); // 1.2 minutes
}, 72000);
return interval; return interval;
} }

View File

@ -162,7 +162,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({ await client.util.authClient.createUser({
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
name: member.username, name: member.username,
user_id: `auth0|${member.id}`, user_id: `${member.id}`,
connection: 'Staff-Database', connection: 'Staff-Database',
email_verified: true, email_verified: true,
app_metadata: { app_metadata: {
@ -175,7 +175,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
} }
channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`); channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
@ -207,7 +207,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({ await client.util.authClient.createUser({
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
name: member.username, name: member.username,
user_id: `auth0|${member.id}`, user_id: `${member.id}`,
connection: 'Staff-Database', connection: 'Staff-Database',
email_verified: true, email_verified: true,
app_metadata: { app_metadata: {
@ -220,7 +220,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
} }
channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`); channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
@ -253,7 +253,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({ await client.util.authClient.createUser({
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
name: member.username, name: member.username,
user_id: `auth0|${member.id}`, user_id: `${member.id}`,
connection: 'Staff-Database', connection: 'Staff-Database',
email_verified: true, email_verified: true,
app_metadata: { app_metadata: {
@ -266,7 +266,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
} }
channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`); channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
@ -299,7 +299,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({ await client.util.authClient.createUser({
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
name: member.username, name: member.username,
user_id: `auth0|${member.id}`, user_id: `${member.id}`,
connection: 'Staff-Database', connection: 'Staff-Database',
email_verified: true, email_verified: true,
app_metadata: { app_metadata: {
@ -312,7 +312,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
} }
channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`); channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
@ -345,7 +345,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({ await client.util.authClient.createUser({
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
name: member.username, name: member.username,
user_id: `auth0|${member.id}`, user_id: `${member.id}`,
connection: 'Staff-Database', connection: 'Staff-Database',
email_verified: true, email_verified: true,
app_metadata: { app_metadata: {
@ -358,7 +358,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
} }
channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`); channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
@ -391,7 +391,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({ await client.util.authClient.createUser({
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
name: member.username, name: member.username,
user_id: `auth0|${member.id}`, user_id: `${member.id}`,
connection: 'Staff-Database', connection: 'Staff-Database',
email_verified: true, email_verified: true,
app_metadata: { app_metadata: {
@ -404,7 +404,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
email: acknowledgement.emailAddress, email: acknowledgement.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP', connection_id: 'con_T3ELEx2reigKMSlP',
}); });
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`); channel.createMessage(`__**Library of Code Inc | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
} }
channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`); channel.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
@ -504,6 +504,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
client.util.signale.time('pagerint'); client.util.signale.time('pagerint');
await start(client); await start(client);
client.util.signale.timeEnd('pagerint'); client.util.signale.timeEnd('pagerint');
}, 300000); // 30 minutes
}, 60000 * 30);
return interval; return interval;
} }