Merge branch 'refactor/multi' into dev
commit
ef777ea4e1
|
@ -183,6 +183,9 @@ export default class Queue {
|
|||
return this.queues.score.add('score::inquiry', { inqID, userID, name, type, reason });
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public updateScore(score: ScoreInterface, total: number, activity: number, roles: number, moderation: number, cloudServices: number, other: number, staff: number) {
|
||||
return this.queues.score.add('score::update', { score, total, activity, roles, moderation, cloudServices, other, staff });
|
||||
}
|
||||
|
|
|
@ -2,19 +2,9 @@
|
|||
/* eslint-disable no-continue */
|
||||
/* eslint-disable one-var-declaration-per-line */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import axios from 'axios';
|
||||
import { Message, TextChannel } from 'eris';
|
||||
import { Client } from '../class';
|
||||
|
||||
interface CSResponse {
|
||||
found: boolean,
|
||||
tier: number,
|
||||
totalReferrals?: number,
|
||||
createdAt?: Date,
|
||||
warns?: Date[],
|
||||
locks?: Date[],
|
||||
deletes?: Date[],
|
||||
}
|
||||
import { CloudServicesUtil } from '../util';
|
||||
|
||||
let interval: NodeJS.Timeout;
|
||||
|
||||
|
@ -116,8 +106,8 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
if (activity > (Math.log1p(getTotalMessageCount(client)) * 12)) activity = Math.floor((Math.log1p(getTotalMessageCount(client)) * 12));
|
||||
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) staff = 20;
|
||||
|
||||
const response = <CSResponse> (await axios.get(`https://api.cloud.libraryofcode.org/wh/score?id=${member.user.id}&authorization=${client.config.internalKey}`)).data;
|
||||
if (response.found === true) {
|
||||
const response = await CloudServicesUtil.fetchAccountStatus(member.user.id, client.config.internalKey);
|
||||
if (response || response.found === true) {
|
||||
let negatives = 0;
|
||||
let positives = 0;
|
||||
if (response.createdAt) {
|
||||
|
@ -197,12 +187,17 @@ export default async function calculateScore(client: Client): Promise<NodeJS.Tim
|
|||
|
||||
total = Math.floor(((total + activity + roles + moderation + cloudServices + staff + other) * 5.13) * 1.87);
|
||||
|
||||
client.queue.updateScore(score, total, activity, roles, moderation, cloudServices, other, staff);
|
||||
// client.queue.updateScore(score, total, activity, roles, moderation, cloudServices, other, staff);
|
||||
|
||||
client.db.Score.updateOne({ userID: score.userID }, { $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } }).exec();
|
||||
if (!score.pin || score.pin?.length < 1) {
|
||||
client.db.Score.updateOne({ userID: score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } }).exec();
|
||||
}
|
||||
}
|
||||
};
|
||||
await start();
|
||||
interval = setInterval(async () => {
|
||||
await start();
|
||||
}, 1800000);
|
||||
}, 3600000);
|
||||
return interval;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import type { MessageContent } from 'eris';
|
||||
import type { Client } from '../class';
|
||||
|
||||
export default class MessageUtil {
|
||||
static async sendDirectMessage(content: MessageContent, userID: string, client: Client) {
|
||||
const dmChannel = await client.getDMChannel(userID);
|
||||
if (!dmChannel) throw new Error(`DM Channel for user ${userID} doesn't exist.`);
|
||||
return dmChannel.createMessage(content);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue