update score calculations
parent
286d720c2a
commit
298d7c82f9
|
@ -64,7 +64,7 @@ export default class Score extends Command {
|
||||||
else totalScore = `${score.total}`;
|
else totalScore = `${score.total}`;
|
||||||
|
|
||||||
if (score.activity < 10) activityScore = '---';
|
if (score.activity < 10) activityScore = '---';
|
||||||
else if (score.activity > Math.floor((Math.log1p(1000 + 300 + 200) * 12))) activityScore = String(Math.floor((Math.log1p(1000 + 300 + 200) * 12)));
|
else if (score.activity > Math.floor((Math.log1p(5000 + 300 + 200 + 100) * 12))) activityScore = String(Math.floor((Math.log1p(5000 + 300 + 200 + 100) * 12)));
|
||||||
else activityScore = `${score.activity}`;
|
else activityScore = `${score.activity}`;
|
||||||
|
|
||||||
if (score.roles <= 0) roleScore = '---';
|
if (score.roles <= 0) roleScore = '---';
|
||||||
|
@ -101,17 +101,21 @@ export default class Score extends Command {
|
||||||
}
|
}
|
||||||
let color = '🔴';
|
let color = '🔴';
|
||||||
embed.setColor('FF0000');
|
embed.setColor('FF0000');
|
||||||
if (score.total >= 280) { color = '🟠'; embed.setColor('FFA500'); }
|
if (score.total >= 300) { color = '🟠'; embed.setColor('FFA500'); }
|
||||||
if (score.total >= 490) { color = '🟡'; embed.setColor('FFFF00'); }
|
if (score.total >= 500) { color = '🟡'; embed.setColor('FFFF00'); }
|
||||||
if (score.total >= 600) { color = '🟢'; embed.setColor('66FF66'); }
|
if (score.total >= 700) { color = '🟢'; embed.setColor('66FF66'); }
|
||||||
embed.addField('Total | 200 - 800', `${color} ${totalScore}`, true);
|
embed.addField('Total | 200 - 800', `${color} ${totalScore}`, true);
|
||||||
embed.addField(`Activity | 10 - ${Math.floor(Math.log1p(1000 + 300 + 200) * 12)}`, activityScore, true);
|
embed.addField(`Activity | 10 - ${Math.floor(Math.log1p(5000 + 300 + 200 + 100) * 12)}`, activityScore, true);
|
||||||
embed.addField('Roles | 1 - 54', roleScore, true);
|
embed.addField('Roles | 1 - 54', roleScore, true);
|
||||||
embed.addField('Moderation | -50 - 2', moderationScore, true);
|
embed.addField('Moderation | -50 - 2', moderationScore, true);
|
||||||
embed.addField('Cloud Services | -20 - 50', cloudServicesScore, true);
|
embed.addField('Cloud Services | -20 - 50', cloudServicesScore, true);
|
||||||
embed.addField('Misc', miscScore, true);
|
embed.addField('Misc', miscScore, true);
|
||||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
if (score.lastUpdate) {
|
||||||
embed.setTimestamp();
|
embed.setFooter('Report last updated', this.client.user.avatarURL);
|
||||||
|
embed.setTimestamp(score.lastUpdate);
|
||||||
|
} else {
|
||||||
|
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||||
|
}
|
||||||
return message.channel.createMessage({ embed });
|
return message.channel.createMessage({ embed });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.util.handleError(err, message, this);
|
return this.client.util.handleError(err, message, this);
|
||||||
|
|
|
@ -10,7 +10,8 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
const { members } = client.guilds.get(client.config.guildID);
|
const { members } = client.guilds.get(client.config.guildID);
|
||||||
|
|
||||||
const general = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('485680288123584525')).getMessages(1000);
|
const general = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('485680288123584525')).getMessages(5000);
|
||||||
|
const media = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('508006539768889354')).getMessages(100);
|
||||||
const programmingSupport = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('506970598631538708')).getMessages(300);
|
const programmingSupport = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('506970598631538708')).getMessages(300);
|
||||||
const cloudSupport = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('546457788184789013')).getMessages(200);
|
const cloudSupport = await (<TextChannel> client.guilds.get(client.config.guildID).channels.get('546457788184789013')).getMessages(200);
|
||||||
for (const member of members.values()) {
|
for (const member of members.values()) {
|
||||||
|
@ -53,14 +54,14 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
||||||
if (moderations?.length > 0) moderation = -moderations.length * 8;
|
if (moderations?.length > 0) moderation = -moderations.length * 8;
|
||||||
else moderation = 2;
|
else moderation = 2;
|
||||||
|
|
||||||
const activityTotal = (general.filter((m) => m.member?.id === member.id).length + programmingSupport.filter((m) => m.member?.id === member.id).length + cloudSupport.filter((m) => m.member?.id === member.id).length);
|
const activityTotal = (general.filter((m) => m.member?.id === member.id).length + media.filter((m) => m.member?.id === member.id).length + programmingSupport.filter((m) => m.member?.id === member.id).length + cloudSupport.filter((m) => m.member?.id === member.id).length);
|
||||||
activity = Math.floor(Math.log1p(activityTotal) * 12);
|
activity = Math.floor(Math.log1p(activityTotal) * 12);
|
||||||
if (activity > (Math.log1p(1000 + 300 + 200) * 12)) activity = Math.floor((Math.log1p(1000 + 300 + 200) * 12));
|
if (activity > (Math.log1p(5000 + 300 + 200) * 12 + 100)) activity = Math.floor((Math.log1p(5000 + 300 + 200 + 100) * 12));
|
||||||
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) staff = 20;
|
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) staff = 20;
|
||||||
|
|
||||||
total = Math.floor(((total + activity + roles + moderation + cloudServices + staff) * 5.13) * 1.87);
|
total = Math.floor(((total + activity + roles + moderation + cloudServices + staff) * 5.13) * 1.87);
|
||||||
|
|
||||||
await score.updateOne({ $set: { total, activity, roles, moderation, cloudServices, staff } });
|
await score.updateOne({ $set: { total, activity, roles, moderation, cloudServices, staff, lastUpdate: new Date() } });
|
||||||
// client.util.signale.debug(`SCORE SET - ${member.username}\nTotal: ${total}\nActivity: ${activity}\nRoles: ${roles}\nModeration: ${moderation}\nCloud Services: ${cloudServices}\nStaff: ${staff}`);
|
// client.util.signale.debug(`SCORE SET - ${member.username}\nTotal: ${total}\nActivity: ${activity}\nRoles: ${roles}\nModeration: ${moderation}\nCloud Services: ${cloudServices}\nStaff: ${staff}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,7 @@ export interface ScoreInterface extends Document {
|
||||||
staff: number,
|
staff: number,
|
||||||
notify: boolean,
|
notify: boolean,
|
||||||
inquiries: [{ name: string, reason: string, date: Date }],
|
inquiries: [{ name: string, reason: string, date: Date }],
|
||||||
|
lastUpdate: Date,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Score: Schema = new Schema({
|
const Score: Schema = new Schema({
|
||||||
|
@ -44,6 +45,7 @@ const Score: Schema = new Schema({
|
||||||
staff: Number,
|
staff: Number,
|
||||||
notify: Boolean,
|
notify: Boolean,
|
||||||
inquiries: Array,
|
inquiries: Array,
|
||||||
|
lastUpdate: Date,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model<ScoreInterface>('Score', Score);
|
export default model<ScoreInterface>('Score', Score);
|
||||||
|
|
Loading…
Reference in New Issue