mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
ok time to work on client
This commit is contained in:
parent
94ea40a8ff
commit
f2deea4bc2
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -31,6 +31,7 @@
|
|||
"@types/bytes": "^3.1.1",
|
||||
"@types/cookie-parser": "^1.4.3",
|
||||
"@types/range-parser": "^1.2.6",
|
||||
"discord-api-types": "^0.37.61",
|
||||
"sass": "^1.57.1",
|
||||
"svelte": "^3.55.1",
|
||||
"vite": "^4.5.0"
|
||||
|
@ -963,9 +964,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/discord-api-types": {
|
||||
"version": "0.37.25",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.25.tgz",
|
||||
"integrity": "sha512-aCwA2sWnL1zPQgTELkkMzQneuWyCXXUjZCUKswesiE6RDCfOfxAPXOHg6ZTlBA5layPSikGCBBRjyh8S3Wzd+A=="
|
||||
"version": "0.37.61",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.61.tgz",
|
||||
"integrity": "sha512-o/dXNFfhBpYHpQFdT6FWzeO7pKc838QeeZ9d91CfVAtpr5XLK4B/zYxQbYgPdoMiTDvJfzcsLW5naXgmHGDNXw=="
|
||||
},
|
||||
"node_modules/discord.js": {
|
||||
"version": "14.7.1",
|
||||
|
@ -2767,9 +2768,9 @@
|
|||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg=="
|
||||
},
|
||||
"discord-api-types": {
|
||||
"version": "0.37.25",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.25.tgz",
|
||||
"integrity": "sha512-aCwA2sWnL1zPQgTELkkMzQneuWyCXXUjZCUKswesiE6RDCfOfxAPXOHg6ZTlBA5layPSikGCBBRjyh8S3Wzd+A=="
|
||||
"version": "0.37.61",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.61.tgz",
|
||||
"integrity": "sha512-o/dXNFfhBpYHpQFdT6FWzeO7pKc838QeeZ9d91CfVAtpr5XLK4B/zYxQbYgPdoMiTDvJfzcsLW5naXgmHGDNXw=="
|
||||
},
|
||||
"discord.js": {
|
||||
"version": "14.7.1",
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
"@types/bytes": "^3.1.1",
|
||||
"@types/cookie-parser": "^1.4.3",
|
||||
"@types/range-parser": "^1.2.6",
|
||||
"discord-api-types": "^0.37.61",
|
||||
"sass": "^1.57.1",
|
||||
"svelte": "^3.55.1",
|
||||
"vite": "^4.5.0"
|
||||
|
|
|
@ -1 +1,31 @@
|
|||
import { REST } from "./DiscordRequests"
|
||||
import { REST } from "./DiscordRequests"
|
||||
import type { APIMessage } from "discord-api-types/v10"
|
||||
|
||||
const EXPIRE_AFTER = 20 * 60 * 1000
|
||||
|
||||
interface MessageCacheObject {
|
||||
expire: number,
|
||||
object: APIMessage
|
||||
}
|
||||
|
||||
export class Client {
|
||||
private readonly token : string
|
||||
private readonly rest : REST
|
||||
private readonly targetChannel : string
|
||||
private messageCache : Map<string, MessageCacheObject> = new Map()
|
||||
|
||||
constructor(token: string, targetChannel: string) {
|
||||
this.token = token
|
||||
this.rest = new REST(token)
|
||||
this.targetChannel = targetChannel
|
||||
}
|
||||
|
||||
fetchMessage(id: string, cache: boolean = true) {
|
||||
if (cache && this.messageCache.has(id)) {
|
||||
let cachedMessage = this.messageCache.get(id)!
|
||||
if (cachedMessage.expire >= Date.now()) {
|
||||
return cachedMessage.object
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue