score message basic classifications

pull/29/head
Matthew 2020-09-28 00:06:51 -04:00
parent 5e77745036
commit f3fa7560f3
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 18 additions and 3 deletions

View File

@ -78,10 +78,25 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
if (roles > 54) roles = 54;
const moderations = await client.db.Moderation.find({ userID: member.user.id });
if (moderations?.length > 0) moderation = -moderations.length * 8;
else moderation = 2;
if (moderations?.length > 0) {
moderation = -moderations.length * 8;
for (const mod of moderations) {
const testDate = (new Date(new Date(mod.date).setHours(2190)));
if (testDate > new Date()) moderation -= 15;
}
} else moderation = 2;
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);
let messageCountTotal = 0;
const allMessagesArray = [...general, ...media, ...programmingSupport, ...cloudSupport];
for (const msg of allMessagesArray.filter((m) => m.member?.id === member.id)) {
if (!msg.content) continue;
if (msg.content.length < 5) continue;
// eslint-disable-next-line no-plusplus
messageCountTotal++;
}
const activityTotal = messageCountTotal;
activity = Math.floor(Math.log1p(activityTotal) * 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;