Compare commits

..

No commits in common. "master" and "ctx" have entirely different histories.
master ... ctx

19 changed files with 202 additions and 289 deletions

View File

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

128
package-lock.json generated
View File

@ -27,7 +27,7 @@
"express": "^4.17.1",
"helmet": "^4.6.0",
"ioredis": "^4.28.2",
"jsonwebtoken": "^9.0.0",
"jsonwebtoken": "^8.5.1",
"mathjs": "^10.0.0",
"moment": "^2.29.1",
"mongoose": "^6.1.1",
@ -2298,54 +2298,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": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
@ -5195,18 +5147,24 @@
}
},
"node_modules/jsonwebtoken": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz",
"integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==",
"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": "^4.17.21",
"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": "^7.3.8"
"semver": "^5.6.0"
},
"engines": {
"node": ">=12",
"npm": ">=6"
"node": ">=4",
"npm": ">=1.4.28"
}
},
"node_modules/jsonwebtoken/node_modules/jwa": {
@ -5228,6 +5186,14 @@
"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": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
@ -5277,54 +5243,6 @@
"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": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz",
@ -6438,7 +6356,7 @@
"version": "17.1.3",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-17.1.3.tgz",
"integrity": "sha512-tVtvNSOOqlq75rUgwLeDAEQoLIiBqmRg0/zedpI6fuqIocIkuxG23A7FIl1oVSkuSMMLgcOP5kVhNETmsmjvPw==",
"deprecated": "< 19.2.0 is no longer supported",
"deprecated": "< 18.1.0 is no longer supported",
"hasInstallScript": true,
"dependencies": {
"cross-fetch": "3.1.5",

View File

@ -16,8 +16,8 @@
"@types/cron": "^1.7.3",
"@types/express": "^4.17.13",
"@types/helmet": "^0.0.48",
"@types/ioredis": "4.28.10",
"@types/jsonwebtoken": "^8.5.6",
"@types/ioredis": "4.28.10",
"@types/node": "^16.11.12",
"@types/nodemailer": "^6.4.4",
"@types/puppeteer": "^5.4.4",
@ -42,6 +42,7 @@
"axios": "^0.24.0",
"body-parser": "^1.19.0",
"bull": "^4.1.1",
"cheerio": "^1.0.0-rc.10",
"cr-db": "git+https://gitlab.libraryofcode.org/engineering/community-relations/database.git",
"cron": "^1.8.2",
"eris": "^0.16.1",
@ -49,13 +50,14 @@
"express": "^4.17.1",
"helmet": "^4.6.0",
"ioredis": "^4.28.2",
"jsonwebtoken": "^9.0.0",
"jsonwebtoken": "^8.5.1",
"mathjs": "^10.0.0",
"moment": "^2.29.1",
"mongoose": "^6.1.1",
"nanoid": "^3.1.30",
"nodemailer": "^6.7.2",
"pluris": "^0.3.7",
"puppeteer": "^17.1.3",
"sd-notify": "^2.8.0",
"signale": "^1.4.0",
"stock-info": "^1.5.1",

View File

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

View File

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

View File

@ -78,8 +78,8 @@ export default class Queue {
members.forEach(async member => {
const resolvedMember = await this.client.getRESTGuildMember(this.client.config.guildID, member.id);
calculateReport(this.client, resolvedMember, [...general, ...programmingSupport, ...programmingSupport2, ...cloudSupport, ...projectMessages])
});
});
})
})
historialCommunityReportJob.start();
clearOldHistoricalReportsJob.start();

View File

@ -5,7 +5,7 @@
import PhoneNumber from 'awesome-phonenumber';
import axios from 'axios';
import { Message, TextChannel } from 'eris';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import { Client, Command, RichEmbed } from '../class';
export default class Callback extends Command {
constructor(client: Client) {
@ -19,7 +19,7 @@ export default class Callback extends Command {
this.enabled = false;
}
public async run(ctx: CmdContext) {
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
if (message.channel.type === 0) await message.delete();
const member = this.mainGuild.members.get(message.author.id);

View File

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

View File

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

View File

@ -3,7 +3,7 @@
*/
import { Message } from 'eris';
import { Client, CmdContext, Command } from '../class';
import { Client, Command } from '../class';
import { Misc as MiscPBXActions } from '../pbx';
export default class Intercom extends Command {
@ -17,7 +17,7 @@ export default class Intercom extends Command {
this.enabled = false;
}
public async run(ctx: CmdContext) {
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const loading = await this.loading(message.channel, 'Synthesizing text...');

View File

@ -5,7 +5,7 @@
/* eslint-disable default-case */
import jwt from 'jsonwebtoken';
import { Message } from 'eris';
import { Client, CmdContext, Command } from '../class';
import { Client, Command } from '../class';
export default class Offer extends Command {
constructor(client: Client) {
@ -19,7 +19,7 @@ export default class Offer extends Command {
this.enabled = false;
}
public async run(ctx: CmdContext) {
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Could not find member.');

View File

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

View File

@ -4,7 +4,7 @@
import { Message } from 'eris';
import { apply as Apply } from '.';
import { Client, CmdContext, Command } from '../class';
import { Client, Command } from '../class';
export default class SSS_Create_Account extends Command {
public applyCommand: Apply;
@ -19,7 +19,7 @@ export default class SSS_Create_Account extends Command {
this.enabled = false;
}
public async run(ctx: CmdContext) {
public async run(message: Message) {
try {
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.');

View File

@ -4,7 +4,7 @@
import { randomBytes } from 'crypto';
import { Message, TextChannel } from 'eris';
import { Client, CmdContext, Command, LocalStorage } from '../class';
import { Client, Command, LocalStorage } from '../class';
export default class StoreMessages extends Command {
constructor(client: Client) {
@ -18,7 +18,7 @@ export default class StoreMessages extends Command {
this.enabled = false;
}
public async run(ctx: CmdContext) {
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
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.');

View File

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

View File

@ -3,20 +3,20 @@ import { Client } from '../class';
import { CloudServicesUtil } from '../util';
export function getTotalMessageCount(client: Client): number {
const projectChannels: TextChannel[] = [];
for (const c of client.guilds.get(client.config.guildID).channels.filter((ch) => ch.type === 0)) {
const chan = <TextChannel> c;
if (chan.parentID !== '701591772186411108') continue;
projectChannels.push(chan);
const projectChannels: TextChannel[] = [];
for (const c of client.guilds.get(client.config.guildID).channels.filter((ch) => ch.type === 0)) {
const chan = <TextChannel> c;
if (chan.parentID !== '701591772186411108') continue;
projectChannels.push(chan);
}
return (projectChannels.length * 200) + 2200 + 300 + 100 + 200;
}
return (projectChannels.length * 200) + 2200 + 300 + 100 + 200;
}
export default async function calculateReport(client: Client, member: Member, allMessagesArray: Message<TextChannel>[]) {
if (member.bot) return;
let score = await client.db.mongo.Score.findOne({ userID: member.user.id });
if (!score) {
const data: {
export default async function(client: Client, member: Member, allMessagesArray: Message<TextChannel>[]) {
if (member.bot) return;
let score = await client.db.mongo.Score.findOne({ userID: member.user.id });
if (!score) {
const data: {
userID: string,
total: number,
activity: number,
@ -43,132 +43,127 @@ export default async function calculateReport(client: Client, member: Member, al
lastUpdated: new Date(),
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();
client.util.signale.debug(`SCORE INIT - ${member.username}`);
}
score = await (new client.db.mongo.Score(data)).save();
client.util.signale.debug(`SCORE INIT - ${member.username}`);
}
// eslint-disable-next-line prefer-const
// eslint-disable-next-line one-var-declaration-per-line
// eslint-disable-next-line one-var
let total = 0,
activity = 0,
roles = 0,
moderation = 0,
cloudServices = 0,
other = 0,
staff = 0;
// eslint-disable-next-line prefer-const
// eslint-disable-next-line one-var-declaration-per-line
// eslint-disable-next-line one-var
let total = 0, activity = 0, roles = 0, moderation = 0, cloudServices = 0, other = 0, staff = 0;
cloudServices = 0;
roles = Math.floor(member.roles.length * 0.50);
if (roles > 54) roles = 54;
roles = Math.floor(member.roles.length * 0.50);
if (roles > 54) roles = 54;
const moderations = await client.db.mongo.Moderation.find({ userID: member.user.id });
let activeMods = 0;
for (const mod of moderations) {
if (mod.type === 1 || mod.type === 4) continue;
const testDate = (new Date(new Date(mod.date).setHours(2190)));
if (testDate > new Date()) { moderation -= 15; activeMods++; }
}
if (activeMods <= 0) moderation = 2;
const moderations = await client.db.mongo.Moderation.find({ userID: member.user.id });
let activeMods = 0;
for (const mod of moderations) {
if (mod.type === 1 || mod.type === 4) continue;
const testDate = (new Date(new Date(mod.date).setHours(2190)));
if (testDate > new Date()) { moderation -= 15; activeMods++; }
}
if (activeMods <= 0) moderation = 2;
let messageCountTotal = 0;
for (const msg of allMessagesArray.filter((m) => m.member?.id === member.id)) {
if (!msg.content) continue;
if (msg.content.length <= 5) continue;
// eslint-disable-next-line no-plusplus
messageCountTotal++;
}
let messageCountTotal = 0;
for (const msg of allMessagesArray.filter((m) => m.member?.id === member.id)) {
if (!msg.content) continue;
if (msg.content.length <= 5) continue;
// eslint-disable-next-line no-plusplus
messageCountTotal++;
}
const activityTotal = messageCountTotal;
activity = Math.floor(Math.log1p(activityTotal) * 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;
const activityTotal = messageCountTotal;
activity = Math.floor(Math.log1p(activityTotal) * 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;
const response = await CloudServicesUtil.fetchAccountStatus(member.user.id, client.config.internalKey);
if (response || response?.found === true) {
let negatives = 0;
let positives = 0;
if (response.createdAt) {
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
if (csCreatedTestDate > new Date()) {
negatives -= 10;
const response = await CloudServicesUtil.fetchAccountStatus(member.user.id, client.config.internalKey);
if (response || response?.found === true) {
let negatives = 0;
let positives = 0;
if (response.createdAt) {
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
if (csCreatedTestDate > new Date()) {
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;
for (const warn of response.warns) {
const date = (new Date(new Date(warn).setHours(730)));
if (date > new Date()) { negatives -= 2; warns++; }
const discordAccountCreatedAtTestDate = (new Date(new Date(new Date(member.user.createdAt)).setHours(730)));
if (discordAccountCreatedAtTestDate > new Date()) {
other -= 10;
}
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++; }
const joinedAtTestDate = (new Date(new Date(new Date(member.joinedAt)).setHours(420)));
if (joinedAtTestDate > new Date()) {
other -= 30;
}
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;
}
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();
}
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) {
console.log(interaction.data);
interaction.createMessage('.');
interaction.createMessage('HELP ME PLEASE');
}
}

View File

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

View File

@ -162,7 +162,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({
email: acknowledgement.emailAddress,
name: member.username,
user_id: `${member.id}`,
user_id: `auth0|${member.id}`,
connection: 'Staff-Database',
email_verified: true,
app_metadata: {
@ -207,7 +207,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({
email: acknowledgement.emailAddress,
name: member.username,
user_id: `${member.id}`,
user_id: `auth0|${member.id}`,
connection: 'Staff-Database',
email_verified: true,
app_metadata: {
@ -253,7 +253,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({
email: acknowledgement.emailAddress,
name: member.username,
user_id: `${member.id}`,
user_id: `auth0|${member.id}`,
connection: 'Staff-Database',
email_verified: true,
app_metadata: {
@ -299,7 +299,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({
email: acknowledgement.emailAddress,
name: member.username,
user_id: `${member.id}`,
user_id: `auth0|${member.id}`,
connection: 'Staff-Database',
email_verified: true,
app_metadata: {
@ -345,7 +345,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({
email: acknowledgement.emailAddress,
name: member.username,
user_id: `${member.id}`,
user_id: `auth0|${member.id}`,
connection: 'Staff-Database',
email_verified: true,
app_metadata: {
@ -391,7 +391,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
await client.util.authClient.createUser({
email: acknowledgement.emailAddress,
name: member.username,
user_id: `${member.id}`,
user_id: `auth0|${member.id}`,
connection: 'Staff-Database',
email_verified: true,
app_metadata: {
@ -504,7 +504,6 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
client.util.signale.time('pagerint');
await start(client);
client.util.signale.timeEnd('pagerint');
// 30 minutes
}, 60000 * 30);
}, 300000);
return interval;
}