score fixes & factorizations
parent
53b77eba2d
commit
a6291c715b
|
@ -18,6 +18,7 @@ export default class Score extends Command {
|
||||||
let member: Member;
|
let member: Member;
|
||||||
if (args[0] === 'notify') {
|
if (args[0] === 'notify') {
|
||||||
member = message.member;
|
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 });
|
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) 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 } });
|
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)) {
|
if (!args[0] || !this.checkCustomPermissions(message.member, 2)) {
|
||||||
member = message.member;
|
member = message.member;
|
||||||
|
if (!member) return this.error(message.channel, 'Member not found.');
|
||||||
} else {
|
} else {
|
||||||
member = this.client.util.resolveMember(args[0], this.mainGuild);
|
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[1] === 'hard') {
|
||||||
if (args.length < 3) return this.client.commands.get('help').run(message, [this.name]);
|
if (args.length < 3) return this.client.commands.get('help').run(message, [this.name]);
|
||||||
const name = args.slice(2).join(' ').split(':')[0];
|
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 });
|
const score = await this.client.db.Score.findOne({ userID: member.user.id });
|
||||||
let totalScore = '0';
|
let totalScore = '0';
|
||||||
let activityScore = '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(`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('Roles | 1 to N/A', roleScore || 'N/C', true);
|
||||||
embed.addField('Moderation | N/A to 2' || 'N/C', moderationScore, 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('Other', otherScore || 'N/C', true);
|
||||||
embed.addField('Misc', miscScore || 'N/C', true);
|
embed.addField('Misc', miscScore || 'N/C', true);
|
||||||
if (score.lastUpdate) {
|
if (score.lastUpdate) {
|
||||||
|
|
|
@ -76,9 +76,11 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
||||||
if (response.found === true) {
|
if (response.found === true) {
|
||||||
let negatives = 0;
|
let negatives = 0;
|
||||||
let positives = 0;
|
let positives = 0;
|
||||||
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
|
if (response.createdAt) {
|
||||||
if (csCreatedTestDate > new Date()) {
|
const csCreatedTestDate = (new Date(new Date(response.createdAt).setHours(730)));
|
||||||
negatives -= 10;
|
if (csCreatedTestDate > new Date()) {
|
||||||
|
negatives -= 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (response.warns.length === 0) positives += 5;
|
if (response.warns.length === 0) positives += 5;
|
||||||
else {
|
else {
|
||||||
|
@ -94,12 +96,13 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
||||||
if (date > new Date()) negatives -= 5;
|
if (date > new Date()) negatives -= 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (response.deletes.length === 0) {
|
if (response.deletes.length > 0) {
|
||||||
for (const del of response.deletes) {
|
for (const del of response.deletes) {
|
||||||
const date = (new Date(new Date(del).setHours(3650)));
|
const date = (new Date(new Date(del).setHours(3650)));
|
||||||
if (date > new Date()) negatives -= 20;
|
if (date > new Date()) negatives -= 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
positives += Math.floor(response.totalReferrals * 1.17);
|
||||||
if (response.tier === 2) positives += 2;
|
if (response.tier === 2) positives += 2;
|
||||||
else if (response.tier === 3) positives += 3;
|
else if (response.tier === 3) positives += 3;
|
||||||
if (negatives < 0) cloudServices = Math.floor((negatives * 1.2) + (positives * 0.06));
|
if (negatives < 0) cloudServices = Math.floor((negatives * 1.2) + (positives * 0.06));
|
||||||
|
|
Loading…
Reference in New Issue