score fixes & factorizations

pull/29/head
Matthew 2020-09-14 02:49:51 -04:00
parent 53b77eba2d
commit a6291c715b
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
2 changed files with 12 additions and 5 deletions

View File

@ -18,6 +18,7 @@ export default class Score extends Command {
let member: Member;
if (args[0] === 'notify') {
member = message.member;
if (!member) return this.error(message.channel, 'Member not found.');
const score = await this.client.db.Score.findOne({ userID: message.author.id });
if (!score) return this.error(message.channel, 'Score not calculated yet.');
if (!score.notify) await this.client.db.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
@ -34,8 +35,10 @@ export default class Score extends Command {
}
if (!args[0] || !this.checkCustomPermissions(message.member, 2)) {
member = message.member;
if (!member) return this.error(message.channel, 'Member not found.');
} else {
member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Member not found.');
if (args[1] === 'hard') {
if (args.length < 3) return this.client.commands.get('help').run(message, [this.name]);
const name = args.slice(2).join(' ').split(':')[0];
@ -50,6 +53,7 @@ export default class Score extends Command {
}
}
}
if (!member) return this.error(message.channel, 'Member not found.');
const score = await this.client.db.Score.findOne({ userID: member.user.id });
let totalScore = '0';
let activityScore = '0';
@ -112,7 +116,7 @@ export default class Score extends Command {
embed.addField(`Activity | 10 to ${Math.floor(Math.log1p(5000 + 300 + 200 + 100) * 12)}`, activityScore || 'N/C', true);
embed.addField('Roles | 1 to N/A', roleScore || 'N/C', true);
embed.addField('Moderation | N/A to 2' || 'N/C', moderationScore, true);
embed.addField('Cloud Services | N/A to 10', cloudServicesScore || 'N/C', true);
embed.addField('Cloud Services | N/A to 10+', cloudServicesScore || 'N/C', true);
embed.addField('Other', otherScore || 'N/C', true);
embed.addField('Misc', miscScore || 'N/C', true);
if (score.lastUpdate) {

View File

@ -76,9 +76,11 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
if (response.found === true) {
let negatives = 0;
let positives = 0;
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
if (csCreatedTestDate > new Date()) {
negatives -= 10;
if (response.createdAt) {
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
if (csCreatedTestDate > new Date()) {
negatives -= 10;
}
}
if (response.warns.length === 0) positives += 5;
else {
@ -94,12 +96,13 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
if (date > new Date()) negatives -= 5;
}
}
if (response.deletes.length === 0) {
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));