aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database.ts26
-rw-r--r--src/hypixelCached.ts2
2 files changed, 15 insertions, 13 deletions
diff --git a/src/database.ts b/src/database.ts
index a1178bc..a7f8f0d 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -4,7 +4,7 @@
import * as constants from './constants'
import * as cached from './hypixelCached'
-import { Collection, Db, FilterQuery, MongoClient } from 'mongodb'
+import { Collection, Db, MongoClient } from 'mongodb'
import NodeCache from 'node-cache'
import { CleanMember } from './cleaners/skyblock/member'
@@ -26,7 +26,7 @@ const cachedLeaderboards: Map<string, any> = new Map()
let client: MongoClient
let database: Db
-let memberLeaderboardsCollection: Collection<LeaderboardItem>
+let memberLeaderboardsCollection: Collection<any>
async function connect() {
if (!process.env.db_uri)
@@ -84,7 +84,7 @@ export async function fetchMemberLeaderboard(name: string) {
if (cachedLeaderboards.has(name))
return cachedLeaderboards.get(name)
// typescript forces us to make a new variable and set it this way because it gives an error otherwise
- const query: FilterQuery<any> = {}
+ const query = {}
query[`stats.${name}`] = { '$exists': true }
const sortQuery: any = {}
@@ -130,16 +130,18 @@ export async function updateDatabaseMember(member: CleanMember) {
const leaderboardAttributes = getMemberLeaderboardAttributes(member)
- await memberLeaderboardsCollection.updateOne({
- uuid: member.uuid
- }, {
- '$set': {
- 'stats': leaderboardAttributes,
- 'last_updated': new Date()
+ await memberLeaderboardsCollection.updateOne(
+ {
+ uuid: member.uuid
+ }, {
+ '$set': {
+ 'stats': leaderboardAttributes,
+ 'last_updated': new Date()
+ }
+ }, {
+ upsert: true
}
- }, {
- upsert: true
- })
+ )
}
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index 8852a74..8e630df 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -2,7 +2,7 @@
* Fetch the clean and cached Hypixel API
*/
-import NodeCache, { EventEmitter, Key } from 'node-cache'
+import NodeCache from 'node-cache'
import * as mojang from './mojang'
import * as hypixel from './hypixel'
import { CleanPlayer } from './cleaners/player'