Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as Yup from 'yup'
import { Client } from 'discord.js'
import NotificationManager from '@utils/NotificationManager'
import { CacheManager } from '@utils/Query'

declare global {
interface Window {
Expand All @@ -14,6 +15,7 @@ declare global {
var kodl: Client
var serverlist: Client
var notification: NotificationManager
var get: CacheManager
interface Navigator {
standalone?: boolean
}
Expand Down
10 changes: 9 additions & 1 deletion utils/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ async function viewBot(id: string) {
await Bots.findByIdAndUpdate(id, { $push: { viewMetrix: { count: 0 } } }, { upsert: true })
}

export const get = {
const _get = {
discord: {
user: new DataLoader(
async (ids: string[]) =>
Expand Down Expand Up @@ -1414,6 +1414,14 @@ export const get = {
},
}

export type CacheManager = typeof _get

if (!global.get) {
global.get = _get
}

export const get = global.get

export const update = {
assignToken,
resetBotToken,
Expand Down