Compare commits

...

17 Commits
ctx ... master

19 changed files with 289 additions and 202 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",
@ -42,7 +42,6 @@
"axios": "^0.24.0", "axios": "^0.24.0",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"bull": "^4.1.1", "bull": "^4.1.1",
"cheerio": "^1.0.0-rc.10",
"cr-db": "git+https://gitlab.libraryofcode.org/engineering/community-relations/database.git", "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",
@ -50,14 +49,13 @@
"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",
"nanoid": "^3.1.30", "nanoid": "^3.1.30",
"nodemailer": "^6.7.2", "nodemailer": "^6.7.2",
"pluris": "^0.3.7", "pluris": "^0.3.7",
"puppeteer": "^17.1.3",
"sd-notify": "^2.8.0", "sd-notify": "^2.8.0",
"signale": "^1.4.0", "signale": "^1.4.0",
"stock-info": "^1.5.1", "stock-info": "^1.5.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

@ -78,8 +78,8 @@ 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(); historialCommunityReportJob.start();
clearOldHistoricalReportsJob.start(); clearOldHistoricalReportsJob.start();

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

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

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

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

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

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

@ -10,9 +10,9 @@ export function getTotalMessageCount(client: Client): number {
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) {
@ -50,8 +50,13 @@ export default async function(client: Client, member: Member, allMessagesArray:
// 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;

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: {
@ -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: {
@ -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: {
@ -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: {
@ -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: {
@ -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: {
@ -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;
} }