redo hist x2
parent
8db4d46835
commit
da7e720a2c
|
@ -20,13 +20,12 @@ export default class Score_Hist extends Command {
|
|||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['score', 'hist']);
|
||||
let user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
|
||||
if (!user) {
|
||||
const sc = await this.client.db.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
|
||||
user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user;
|
||||
}
|
||||
const score = await this.client.db.Score.findOne({ userID: user.id }).lean().exec();
|
||||
if (!user) return this.error(message.channel, 'Member not found.');
|
||||
const hists = await this.client.db.ScoreHistorical.find({ userID: user.id }).lean().exec();
|
||||
if (!hists) return this.error(message.channel, 'No history found.');
|
||||
|
@ -38,7 +37,8 @@ export default class Score_Hist extends Command {
|
|||
const cloudServicesArray: number[] = [];
|
||||
const otherArray: number[] = [];
|
||||
const miscArray: number[] = [];
|
||||
for (const hist of hists.reverse()) {
|
||||
|
||||
for (const hist of hists) {
|
||||
totalArray.push(hist.report.total);
|
||||
activityArray.push(hist.report.activity);
|
||||
moderationArray.push(hist.report.moderation);
|
||||
|
@ -46,55 +46,6 @@ export default class Score_Hist extends Command {
|
|||
cloudServicesArray.push(hist.report.cloudServices);
|
||||
otherArray.push(hist.report.other);
|
||||
miscArray.push(hist.report.staff);
|
||||
let totalScore = '0';
|
||||
let activityScore = '0';
|
||||
let moderationScore = '0';
|
||||
let roleScore = '0';
|
||||
let cloudServicesScore = '0';
|
||||
let otherScore = '0';
|
||||
let miscScore = '0';
|
||||
|
||||
if (hist.report.total < 200) totalScore = '---';
|
||||
else if (hist.report.total > 800) totalScore = '800';
|
||||
else totalScore = `${hist.report.total}`;
|
||||
|
||||
if (hist.report.activity < 10) activityScore = '---';
|
||||
else if (hist.report.activity > Math.floor((Math.log1p(getTotalMessageCount(this.client)) * 12))) activityScore = String(Math.floor((Math.log1p(getTotalMessageCount(this.client)) * 12)));
|
||||
else activityScore = `${hist.report.activity}`;
|
||||
|
||||
if (hist.report.roles <= 0) roleScore = '---';
|
||||
else if (hist.report.roles > 54) roleScore = '54';
|
||||
else roleScore = `${hist.report.roles}`;
|
||||
|
||||
moderationScore = `${hist.report.moderation}`;
|
||||
|
||||
if (hist.report.other === 0) otherScore = '---';
|
||||
else otherScore = `${hist.report.other}`;
|
||||
|
||||
if (hist.report.staff <= 0) miscScore = '---';
|
||||
else miscScore = `${hist.report.staff}`;
|
||||
|
||||
if (hist.report.cloudServices === 0) cloudServicesScore = '---';
|
||||
else if (hist.report.cloudServices > 10) cloudServicesScore = '10';
|
||||
else cloudServicesScore = `${hist.report.cloudServices}`;
|
||||
|
||||
let data = '';
|
||||
let hardInquiries = 0;
|
||||
const inquiries: InquiryInterface[] = [];
|
||||
if (hist.inquiries?.length > 0) {
|
||||
for (const h of hist.inquiries) {
|
||||
const inq = await this.client.db.Inquiry.findOne({ _id: h });
|
||||
inquiries.push(inq);
|
||||
}
|
||||
}
|
||||
if (inquiries?.length > 0) {
|
||||
inquiries.forEach((inq) => {
|
||||
const testDate = (new Date(new Date(inq.date).setHours(1460)));
|
||||
// eslint-disable-next-line no-plusplus
|
||||
if (testDate > new Date()) hardInquiries++;
|
||||
});
|
||||
data += `__CommScore™:__ ${totalScore}\n__Activity:__ ${activityScore}\n__Roles:__ ${roleScore}\n__Moderation:__ ${moderationScore}\n__Cloud Services:__ ${cloudServicesScore}\n__Other:__ ${otherScore}\n__Misc:__ ${miscScore}\n\n__Hard Inquiries:__ ${hardInquiries}\n__Soft Inquiries:__ ${score.softInquiries?.length ?? '0'}`;
|
||||
}
|
||||
}
|
||||
|
||||
const stat = {
|
||||
|
|
Loading…
Reference in New Issue