score hist fix x3

master
Matthew 2021-07-08 17:22:53 -04:00
parent da7e720a2c
commit c3d32dbc76
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 12 additions and 9 deletions

View File

@ -2,10 +2,9 @@
/* eslint-disable no-continue */
/* eslint-disable default-case */
import { median, mode, mean } from 'mathjs';
import { Message } from 'eris';
import { Message, User } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../intervals/score';
import { InquiryInterface } from '../models';
export default class Score_Hist extends Command {
constructor(client: Client) {
@ -13,19 +12,23 @@ export default class Score_Hist extends Command {
this.name = 'hist';
this.description = 'Pulls a Community Report history for a user.';
this.usage = `${this.client.config.prefix}score hist <member>`;
this.permissions = 4;
this.permissions = 0;
this.guildOnly = false;
this.enabled = true;
}
public async run(message: Message, args: string[]) {
try {
if (!args[0]) return this.client.commands.get('help').run(message, ['score', 'hist']);
let user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
let user: User;
if (!this.checkCustomPermissions(message.member, 4)) user = message.author;
else if (!args[0]) user = message.author;
else {
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;
}
}
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.');
@ -114,7 +117,7 @@ export default class Score_Hist extends Command {
embed.setTitle('Historical Community Report');
embed.setAuthor(user.username, user.avatarURL);
embed.setThumbnail(user.avatarURL);
embed.setDescription(`__**Statistical Averages**__\n**CommScore™ Mean:** ${totalMean} | **CommScore™ Mode:** ${totalMode} | **CommScore™ Median:** ${totalMedian}\n\n**Activity Mean:** ${activityMean}\n**Roles Mean:** ${roleMean}\n**Moderation Mean:** ${moderationMean}\n**Cloud Services Mean:** ${cloudServicesMean}\n**Other Mean:** ${otherMean}\n**Misc Mean:** ${miscMean}`);
embed.setDescription(`__**Statistical Averages**__\n**CommScore™ Mean:** ${Number(totalMean).toFixed(2)} | **CommScore™ Mode:** ${Number(totalMode).toFixed(2)} | **CommScore™ Median:** ${Number(totalMedian).toFixed(2)}\n\n**Activity Mean:** ${Number(activityMean).toFixed(2)}\n**Roles Mean:** ${Number(roleMean).toFixed(2)}\n**Moderation Mean:** ${Number(moderationMean).toFixed(2)}\n**Cloud Services Mean:** ${Number(cloudServicesMean).toFixed(2)}\n**Other Mean:** ${Number(otherMean).toFixed(2)}\n**Misc Mean:** ${Number(miscMean).toFixed(2)}`);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
return message.channel.createMessage({ embed });